On 10/18/2011 10:09 AM, Wen Congyang wrote:
At 10/18/2011 09:32 AM, Wen Congyang Write:
At 10/18/2011 01:04 AM, Eric Blake Write:
On 10/17/2011 11:03 AM, Eric Blake wrote:
On 10/17/2011 10:17 AM, Alex Jia wrote:
Eric,
It's latest libvirt upstream, current commit id is commit 0a71c79.
# rpm -q glibc
glibc-2.12-1.42.el6.x86_64
430 if (strchr(toescape, *cur))
CC libvirt_util_la-buf.lo
util/buf.c: In function 'virBufferEscape':
util/buf.c:430: warning: logical '&&' with non-zero constant will
always
evaluate as true [-Wlogical-op]
Something's screwy. There's no&& in that line, unless strchr() is a
macro based on your particular compilation flags. I'm suspecting that
this is a case of -D_FORTIFY_SOURCE going awry. I don't see how this
could possibly be a libvirt issue; more likely, it is an issue with the
choice of compiler flags you are using, coupled with an issue in the
system headers causing the preprocessor to expand strchr() into
something that tickles a spurious gcc warning.
Just to make sure, could you show 'make V=1' output, so we know exactly
which compiler flags are in effect?
I can reproduce this problem, here is 'make V=1' output:
=====================================================
make[3]: Entering directory `/root/rpmbuild/BUILD/libvirt-0.9.6/src'
/bin/sh ../libtool --tag=CC --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib -I../gnulib/lib -I../include -I../src/util -I../include -DIN_LIBVIRT -I/usr/include/libxml2 -Wall -W -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var -Wdisabled-optimization -Wbuiltin-macro-redefined -Wmudflap -Wpacked-bitfield-compat -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wno-missing-field-initializers -Wno-sign-compare -Wframe-larger-than=4096 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions -fasynchronous-unwind-tables -fdiagnostics
-s
how-option -funit-at-a-time -Werror -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -MT libvirt_util_la-buf.lo -MD -MP -MF .deps/libvirt_util_la-buf.Tpo -c -o libvirt_util_la-buf.lo `test -f 'util/buf.c' || echo './'`util/buf.c
libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib -I../gnulib/lib -I../include -I../src/util -I../include -DIN_LIBVIRT -I/usr/include/libxml2 -Wall -W -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var -Wdisabled-optimization -Wbuiltin-macro-redefined -Wmudflap -Wpacked-bitfield-compat -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wno-missing-field-initializers -Wno-sign-compare -Wframe-larger-than=4096 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time -Werro
r
-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -MT libvirt_util_la-buf.lo -MD -MP -MF .deps/libvirt_util_la-buf.Tpo -c util/buf.c -fPIC -DPIC -o .libs/libvirt_util_la-buf.o
cc1: warnings being treated as errors
util/buf.c: In function 'virBufferEscape':
util/buf.c:430: error: logical '&&' with non-zero constant will always evaluate as true [-Wlogical-op]
make[3]: *** [libvirt_util_la-buf.lo] Error 1
=====================================================
If I remove -O2, I can build util/buf.c.
I test strchr in a small program:
=====================================================
# cat test.c
#include<stdio.h>
#include<string.h>
int main() {
char *s = "abcdefg";
int chr = (int)'d';
char *d;
d = strchr(s, chr);
if (d)
printf("%s\n", d);
return 0;
}
# gcc -std=c99 -Wall -o test test.c -Wlogical-op -Werror
# gcc -std=c99 -O2 -Wall -o test test.c -Wlogical-op -Werror
cc1: warnings being treated as errors
test.c: In function ‘main’:
test.c:9: error: logical ‘&&’ with non-zero constant will always evaluate as true
# gcc -std=c99 -Wall -o test test.c -Wlogical-op -Werror
# gcc -std=c99 -Wall -o test test.c -Werror
=====================================================
The building failed only when '-O2' and '-Wlogical-op' are specified at the same time.
Thanks
Wen Congyang
Chonyang, thanks for your reply and good example.
Regards,
Alex
I am still investigating this problem.
Thanks
Wen Congyang
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list