]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
build: silence stupid gcc warning on STREQ_NULLABLE
authorEric Blake <eblake@redhat.com>
Mon, 20 Aug 2012 19:05:31 +0000 (13:05 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 21 Aug 2012 15:20:50 +0000 (09:20 -0600)
commit8d8527de32065d7a3168bfbdf58e394b7022fc54
treee72cfa832fa7ec7088d8cac335fc1773e0ce772e
parent7272a92c8109eef0cae16d1ca39bf39ae8018abc
build: silence stupid gcc warning on STREQ_NULLABLE

Our existing STRNEQ_NULLABLE() triggered a warning in gcc 4.7 when
used with a literal NULL argument:

qemumonitorjsontest.c: In function 'testQemuMonitorJSONGetMachines':
qemumonitorjsontest.c:289:5: error: null argument where non-null required (argument 1) [-Werror=nonnull]

even though the strcmp is provably dead when a null argument is
present.  Squelch the warning by refactoring things so that gcc
never sees strcmp() called with NULL arguments (we still compare
NULL as not equal to "", this rewrite merely aids gcc).

Next, gcc has a valid warning about a literal NULLSTR(NULL):

qemumonitorjsontest.c:289:5: error: invalid application of 'sizeof' to a void type [-Werror=pointer-arith]

Of course, you'd never write NULLSTR(NULL) directly, but it is
handy to use through macros.  But the entire part about verify_true()
is unnecessary - gcc already warns about type mismatch with ?:,
without needing to make it more complex.

* src/internal.h (STREQ_NULLABLE, STRNEQ_NULLABLE): Avoid gcc 4.7
stupidity.
(NULLSTR): Simplify, to allow passing compile-time constants.
src/internal.h