[libvirt] Non-zero constant warning on RHEL 6.1 with 0.9.7

Eric Blake eblake at redhat.com
Tue Nov 15 15:56:29 UTC 2011


On 11/15/2011 04:41 AM, Daniel P. Berrange wrote:
>>      while (*cur != 0) {
>> -        if (strchr(toescape, *cur))
>> +        /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
>> +         * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
>> +         */
>> +        char needle[2] = { *cur, 0 };
>> +        if (strstr(toescape, needle))
>>              *out++ = '\\';
> 
> I'm puzzelled that we need this change here, but we have 175 other
> uses of strchr without trouble
> 
>   $ grep strchr src/*/*.c | wc -l
>   174

Rather, look for instances of strchr that have a constant second argument:

$ git grep strchr".*'" src/*/*.c | wc -l
173

vs. those with a variable second argument:

$ git grep strchr"[^']*\$" src/*/*.c | wc -l
3

further, 2 of those 3 have a constant first argument.  So this really
was the only instance of using strchr() with two variable arguments, and
that is the only use-case that can trigger the gcc bug.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111115/0a67f4dd/attachment-0001.sig>


More information about the libvir-list mailing list