Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated methods that return BOOL should return NO instead of 0. #8

Closed
seanm opened this issue Dec 9, 2009 · 5 comments
Closed

Generated methods that return BOOL should return NO instead of 0. #8

seanm opened this issue Dec 9, 2009 · 5 comments

Comments

@seanm
Copy link
Contributor

seanm commented Dec 9, 2009

AnalysisTool (http://www.karppinen.fi/analysistool/) which in turn uses the llvm static analyzer generates warnings for mogenerated code. ex:

  • (BOOL)primitiveIsLeafValue {
    NSNumber *result = [self primitiveIsLeaf];
    return result ? [result boolValue] : 0;
    }

It warns "coercion from 'int' to 'BOOL' may alter its value". Of course, there isn't really anything wrong with the code above, but the warning could be easily silenced by changing that 0 to a NO. That would fix it because the definition of NO includes a cast to BOOL.

This warning is useful in other situations but all these false positives are generating a lot of noise.

@rentzsch
Copy link
Owner

This is a little hard to deal with since we'd need to special-case BOOLs in the machine.m template

@seanm
Copy link
Contributor Author

seanm commented Dec 14, 2009

:( That's a pity. Combined with bug #2, I'm starting to have the impression that mogenerator is difficult to expand upon... :(

@rentzsch
Copy link
Owner

It's not difficult to expound on, it just has to deal with asymmetry between Obj-C types and their NSValue/NSNumber method names. I haven't written a mapper since I haven't needed it for myself yet.

@seanm
Copy link
Contributor Author

seanm commented Jul 21, 2010

@rentzsch
Copy link
Owner

Thanks! Closing.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants