From: Stefan Berger Date: Tue, 15 Nov 2011 17:48:07 +0000 (-0500) Subject: Fix strchr call triggering gcc 4.3 & 4.4 bug X-Git-Tag: v0.9.8-rc1~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39d91e9f880a88026359d941476b35069bcece71;p=thirdparty%2Flibvirt.git Fix strchr call triggering gcc 4.3 & 4.4 bug 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. --- diff --git a/src/util/buf.c b/src/util/buf.c index 5043128a11..206a39a933 100644 --- a/src/util/buf.c +++ b/src/util/buf.c @@ -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++;