From: Eric Blake Date: Wed, 19 Dec 2012 19:28:48 +0000 (-0700) Subject: build: use strchr now that we can work around broken gcc X-Git-Tag: v1.0.2-rc1~357 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=622ceb34ffabf0933c930f37d752bb3d28b305da;p=thirdparty%2Flibvirt.git build: use strchr now that we can work around broken gcc Revert the complex workaround of commit 39d91e9, now that we have a nicer framework for shutting up broken gcc. * src/util/buf.c (virBufferEscape): Simplify. --- diff --git a/src/util/buf.c b/src/util/buf.c index 030dc97808..e5a6ab781e 100644 --- a/src/util/buf.c +++ b/src/util/buf.c @@ -458,6 +458,15 @@ virBufferEscapeSexpr(virBufferPtr buf, virBufferEscape(buf, '\\', "\\'", format, str); } +/* Work around spurious strchr() diagnostics given by -Wlogical-op * + * for gcc < 4.6. Doing it via a local pragma keeps the damage + * smaller than disabling it on the package level. Unfortunately, the + * affected GCCs don't allow diagnostic push/pop which would have + * further reduced the impact. */ +#if BROKEN_GCC_WLOGICALOP +# pragma GCC diagnostic ignored "-Wlogical-op" +#endif + /** * virBufferEscape: * @buf: the buffer to append to @@ -499,11 +508,7 @@ virBufferEscape(virBufferPtr buf, char escape, const char *toescape, cur = str; out = escaped; while (*cur != 0) { - /* 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)) + if (strchr(toescape, *cur)) *out++ = escape; *out++ = *cur; cur++;