summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2022-04-07 12:34:00 +0200
committerRalf Habacker <ralf.habacker@freenet.de>2022-05-01 16:28:51 +0000
commit29946ad7c139c1955cfa01e3e1bc83557529a4c0 (patch)
tree46efeef21dfc8a8b1f700b6d6456e37a26bfae04 /test
parent2e63543b932ad72234e2cb84e29714d56b247dd1 (diff)
downloaddbus-29946ad7c139c1955cfa01e3e1bc83557529a4c0.tar.gz
tests: Fix build warning "dereferencing type-punned pointer will break strict-aliasing rules"
To avoid that build break in test-marshall-recursive-util.c the newly added function _dbus_string_append_buffer_as_hex() is used to print the hex bytes. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'test')
-rw-r--r--test/internals/dbus-marshal-recursive-util.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/test/internals/dbus-marshal-recursive-util.c b/test/internals/dbus-marshal-recursive-util.c
index 0727225a..f05232f9 100644
--- a/test/internals/dbus-marshal-recursive-util.c
+++ b/test/internals/dbus-marshal-recursive-util.c
@@ -2625,13 +2625,28 @@ double_read_value (TestTypeNode *node,
expected = double_from_seed (seed);
if (!_DBUS_DOUBLES_BITWISE_EQUAL (v, expected))
- _dbus_test_fatal ("Expected double %g got %g\n"
- " bits = 0x%" DBUS_INT64_MODIFIER "x vs.\n"
- " bits = 0x%" DBUS_INT64_MODIFIER "x",
- expected, v,
- *(dbus_uint64_t*)(char*)&expected,
- *(dbus_uint64_t*)(char*)&v);
-
+ {
+ DBusString es = _DBUS_STRING_INIT_INVALID;
+ DBusString vs = _DBUS_STRING_INIT_INVALID;
+ if (!_dbus_string_init (&es))
+ goto out;
+ if (!_dbus_string_init (&vs))
+ goto out;
+ if (!_dbus_string_append_buffer_as_hex (&es, &expected, sizeof(double)))
+ goto out;
+ if (!_dbus_string_append_buffer_as_hex (&vs, &v, sizeof(double)))
+ goto out;
+ _dbus_test_fatal ("Expected double %g got %g\n"
+ " bits = 0x%s vs.\n"
+ " bits = 0x%s",
+ expected, v,
+ _dbus_string_get_const_data (&es),
+ _dbus_string_get_const_data (&vs));
+out:
+ _dbus_string_free (&es);
+ _dbus_string_free (&vs);
+ return FALSE;
+ }
return TRUE;
}