• E
    dbus: fix arrays of bools · 96e0d677
    Eric Blake 提交于
    Commit 2aa167ca tried to fix the DBus interaction code to allow
    callers to use native types instead of 4-byte bools.  But in
    fixing the issue, I missed the case of an arrayref; Conrad Meyer
    shows the following valid complaint issued by clang:
    
      CC       util/libvirt_util_la-virdbus.lo
    util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
                GET_NEXT_VAL(dbus_bool_t, bool_val, bool, "%d");
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
                x = (dbustype *)(*xptrptr + (*narrayptr - 1));              \
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.
    
    But fixing that points out that we have NEVER supported arrayrefs
    of sub-int types (byte, i16, u16, and now bool).  Again, while raw
    types promote, arrays do not; so the macros HAVE to deal with both
    size possibilities rather than assuming that an arrayref uses the
    same sizing as the promoted raw type.
    
    Obviously, our testsuite wasn't covering as much as it should have.
    
    * src/util/virdbus.c (GET_NEXT_VAL): Also fix array cases.
    (SET_NEXT_VAL): Fix uses of sub-int arrays.
    * tests/virdbustest.c (testMessageArray, testMessageArrayRef):
    Test it.
    Signed-off-by: NEric Blake <eblake@redhat.com>
    96e0d677
virdbus.c 56.0 KB