(6/15/12 6:35 AM), Dan Carpenter wrote:
On Thu, Jun 14, 2012 at 12:53:52AM -0400, KOSAKI Motohiro wrote:
Hi,
Today, I tried to use 'smatch' for ruby project and I found plenty false positive errors.
They were mainly caused that glibc uses some no smatch recognized attributes. I did apply
following patch myself. (see below)
Is there any more good way? I didn't find a hint from README.
And, I have one unsolved issue. I've seen following annoying error a lot.
/usr/include/bits/xopen_lim.h:122:6: warning: constant 9223372036854775807L is so big it is long long
Because of, /usr/include/limits.h has "#define LONG_MAX 9223372036854775807L" and it is completely
valid on 64bit OS. Is there any way to disable this message when using 64bit?
The way to do this is to add an -m64 to the cgcc command.
make CHECK="~/path/to/smatch/smatch --full-path" \
CC="~/path/to/smatch/cgcc -m64"
Great! this works perfectly.
And it also does seem like Smatch prints out a bunch of garbage...
I'll try turn of it off unless the --spammy flag is used.
Today, I'm playing smatch a while. then I have two feature request for applying
smatch to userland open source project.
1) /usr/include have plenty smatch error. but they don't project author's fault.
please consider to make a way to ignore /usr/include. I can drop them by sed
filter. but it's annoying.
2) many userland project use -include gcc option for improving operating system
portability. (e.g. "gcc -include missing.h", and missing.h has OS unportable
function declarations). It would be great if smatch also have -include option.
I need more detailed explanation of (2). Please think following -I and -include combination.
Makefile
--------------
bar:
$(CC) -I./include-for-foo -include foo.h main.c -o bar
main.c
------------------
#include <stdio.h>
int main(void)
{
printf("foo = %d\n", FOO);
return 0;
}
include-for-foo/foo.h
----------------------
#define FOO 42
current smatch doesn't search ./include-for-foo/foo.h, but gcc and clang do.
I think it's a bug of following.
static void add_cmdline_include(char *filename)
{
int fd = open(filename, O_RDONLY); // Should care -I path too!
if (fd < 0) {
perror(filename);
return;
}
Of course, I know your first target is not userland. Please don't mind if you don't
want bother.
Cheers.
--
To unsubscribe from this list: send the line "unsubscribe smatch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html