perf tools: fix type mismatch - long vs __statfs_word
PATCH 1/1 perf tools: fix type mismatch - long vs __statfs_word
Quoted 1 line
From "
include/uapi/asm-generic/statfs.h" it is seen that "statfs.f_type" is of
type "__statfs_word" which in its turn is "__u32" (unsigned int) for 32-bit systems.
So in case of compilation with "-Werror" following breakage happens:
--->---fs.c: In function ‘fs__valid_mount’:
fs.c:76:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)
^
cc1: all warnings being treated as errors
--->---
Note that now when fs.c is in "lib/api/fs" and in "tools/lib/api/Makefile" CFLAGS has hard-coded "-Werror" this is inevitable even if one builds "perf" with "WERROR=0".
--- tools/lib/api/fs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/api/fs/fs.c +1 -1
@@ -75,7 +75,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long )st_fs.f_type != magic)return -ENOENT ;return 0 ;
Signature · 1 line
1.9.3
+CC acme, Peter
Quoted 41 lines · Alexey Brodkin
From "
include/uapi/asm-generic/statfs.h" it is seen that "statfs.f_type" is of type "__statfs_word" which in its turn is "__u32" (unsigned int) for 32-bit systems.So in case of compilation with "-Werror" following breakage happens:
--->---fs.c: In function ‘fs__valid_mount’:
fs.c:76:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)^cc1: all warnings being treated as errors
--->---Note that now when
fs.cis in "lib/api/fs" and in "tools/lib/api/Makefile" CFLAGS has hard-coded "-Werror" this is inevitable even if one builds "perf" with "WERROR=0".Signed-off-by Alexey Brodkin <[email protected]>Cc Vineet Gupta <[email protected]>Cc Borislav Petkov <[email protected]>Cc Jiri Olsa <[email protected]>Cc Cody P Schafer <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>--- tools/lib/api/fs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/api/fs/fs.c +1
-1@@ -75,7 +75,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long )st_fs.f_type != magic)return -ENOENT ;return 0 ;
Hi Arnaldo, Jiri,
Quoted 14 lines · Alexey Brodkin
Quoted 13 lines
From "
include/uapi/asm-generic/statfs.h" it is seen that "statfs.f_type" is of type "__statfs_word" which in its turn is "__u32" (unsigned int) for 32-bit systems.So in case of compilation with "-Werror" following breakage happens:
--->---fs.c: In function ‘fs__valid_mount’:
fs.c:76:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)^cc1: all warnings being treated as errors
--->---
Quoted 4 lines
Quoted 4 lines
Note that now when
fs.cis in "lib/api/fs" and in "tools/lib/api/Makefile" CFLAGS has hard-coded "-Werror" this is inevitable even if one builds "perf" with "WERROR=0".
I'm wondering if there's a chance to get this patch accepted because for now perf building from 3.15 kernels onward is broken.
Regards,
Alexey ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Em Wed, Aug 13, 2014 at 09:03:49PM +0400, Alexey Brodkin escreveu:
Quoted 9 lines
Quoted 1 line
From "
include/uapi/asm-generic/statfs.h" it is seen that "statfs.f_type" is oftype "
__statfs_word" which in its turn is "__u32" (unsigned int) for 32-bit systems.So in case of compilation with "-Werror" following breakage happens:
--->---fs.c: In function ‘fs__valid_mount’:
fs.c:76:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)
Quoted 7 lines
^cc1: all warnings being treated as errors
--->---Note that now when
fs.cis in "lib/api/fs" and in "tools/lib/api/Makefile" CFLAGS has hard-coded "-Werror" this is inevitable even if one builds "perf" with "WERROR=0".
So we have one more case of comparision involving f_type:
[acme@zoo linux]$ find tools/ -type f | xargs grep -w f_typetools/lib/api/fs/fs.c: else if (st_fs.f_type != magic)tools/lib/api/fs/debugfs.c: else if (st_fs.f_type != (long) DEBUGFS_MAGIC)
[acme@zoo linux]$
Do we have to apply the same fix to that other case as well? Interestingly it does it on a different way, that by your description above would make it fail on 32-bit systems, no?
- Arnaldo
Quoted 26 lines
Signed-off-by Alexey Brodkin <[email protected]>Cc Vineet Gupta <[email protected]>Cc Borislav Petkov <[email protected]>Cc Jiri Olsa <[email protected]>Cc Cody P Schafer <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>--- tools/lib/api/fs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/api/fs/fs.c +1
-1@@ -75,7 +75,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long )st_fs.f_type != magic)return -ENOENT ;return 0 ;Signature · 1 line
1.9.3