[libvirt] [PATCH] build: use strchr now that we can work around broken gcc

Daniel P. Berrange berrange at redhat.com
Wed Dec 19 19:36:29 UTC 2012


On Wed, Dec 19, 2012 at 12:32:54PM -0700, Eric Blake wrote:
> 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.
> ---
>  src/util/buf.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/src/util/buf.c b/src/util/buf.c
> index 030dc97..e5a6ab7 100644
> --- a/src/util/buf.c
> +++ b/src/util/buf.c
> @@ -458,2 +458,2 @@ 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++;


ACK

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list