]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix strchr call triggering gcc 4.3 & 4.4 bug
authorStefan Berger <stefanb@us.ibm.com>
Tue, 15 Nov 2011 17:48:07 +0000 (12:48 -0500)
committerStefan Berger <stefanb@us.ibm.com>
Tue, 15 Nov 2011 20:00:10 +0000 (15:00 -0500)
Replacing the strchr call with two variables through a strstr call.
Calling strchr with two variables triggers a gcc 4.3/4.4
bug when used in combination with -Wlogical-op and at least -O1.

src/util/buf.c

index 5043128a117499cc2c90e83a4c0b88b68068b336..206a39a933dffe6f1c72492366efc27394bbac4a 100644 (file)
@@ -466,7 +466,11 @@ virBufferEscape(virBufferPtr buf, const char *toescape,
     cur = str;
     out = escaped;
     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++ = '\\';
         *out++ = *cur;
         cur++;