Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

C and C Headers have some unsafe code #1

Closed
kbknapp opened this issue Aug 21, 2015 · 8 comments
Closed

C and C Headers have some unsafe code #1

kbknapp opened this issue Aug 21, 2015 · 8 comments

Comments

@kbknapp
Copy link
Owner

kbknapp commented Aug 21, 2015

Since the unsafe counter is naive and counts all C and C++ as unsafe it's strange that some code in .c and .h files is not unsafe. See the example in the README.md...

@kbknapp kbknapp added the bug label Aug 21, 2015
@Vinatorul
Copy link
Collaborator

May be some problem with blank lines? Can you add examples ro repo?

@kbknapp
Copy link
Owner Author

kbknapp commented Aug 21, 2015

I noticed it in the Rust repo (See the example output), but I haven't yet done any real investigating such as creating a quick .c file and seeing what happens.

@Vinatorul
Copy link
Collaborator

It seems to be the same bug as #2.

int  test() {
    return /* test */ 0;    
}

Result is

         Language  Files  Lines  Blanks  Comments  Code  Unsafe (%)
         --------  -----  -----  ------  --------  ----  ----------
         C Header  1      3      0       1         2     1 (50.00%)
         TOML      1      4      0       0         4     
         --------  -----  -----  ------  --------  ----  ----------
Totals:            2      7      0       1         6     1 (16.67%)

@kbknapp
Copy link
Owner Author

kbknapp commented Aug 21, 2015

Makes sense, and now I see why I didn't catch it before! Thanks! 😄

@kbknapp
Copy link
Owner Author

kbknapp commented Aug 21, 2015

#2 found some of the erroneous lines...but not all.

@Vinatorul
Copy link
Collaborator

The only place, where count.code increments before unsafe check is

else if line.contains(ms) {
    debugln!("line contains a multi start");
    count.code += 1;
    is_in_comments = line.contains(count.multi_end().unwrap());
    debugln!("line also contained a multi end: {:?}", is_in_comments);
    continue;
    }

and there is continue

@Vinatorul
Copy link
Collaborator

Let me fix it?

@kbknapp
Copy link
Owner Author

kbknapp commented Aug 21, 2015

That was it! Sorry, I just pushed the patch!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants