chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-bus: fix handling of double parameters in sd_bus_message_append()
[elogind.git]
/
src
/
libsystemd
/
sd-bus
/
test-bus-marshal.c
diff --git
a/src/libsystemd/sd-bus/test-bus-marshal.c
b/src/libsystemd/sd-bus/test-bus-marshal.c
index 8cefc7a154e35de52a8bf1bed9866ec5c8845f0c..d95a03c221a1d1bfec846c07f1fc610f0a3e770d 100644
(file)
--- a/
src/libsystemd/sd-bus/test-bus-marshal.c
+++ b/
src/libsystemd/sd-bus/test-bus-marshal.c
@@
-22,6
+22,7
@@
#include <assert.h>
#include <stdlib.h>
#include <byteswap.h>
#include <assert.h>
#include <stdlib.h>
#include <byteswap.h>
+#include <math.h>
#ifdef HAVE_GLIB
#include <gio/gio.h>
#ifdef HAVE_GLIB
#include <gio/gio.h>
@@
-94,6
+95,8
@@
int main(int argc, char *argv[]) {
_cleanup_fclose_ FILE *ms = NULL;
size_t first_size = 0, second_size = 0, third_size = 0;
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_fclose_ FILE *ms = NULL;
size_t first_size = 0, second_size = 0, third_size = 0;
_cleanup_bus_unref_ sd_bus *bus = NULL;
+ double dbl;
+ uint64_t u64;
r = sd_bus_default_system(&bus);
if (r < 0)
r = sd_bus_default_system(&bus);
if (r < 0)
@@
-145,6
+148,9
@@
int main(int argc, char *argv[]) {
r = sd_bus_message_append_array(m, 'u', NULL, 0);
assert_se(r >= 0);
r = sd_bus_message_append_array(m, 'u', NULL, 0);
assert_se(r >= 0);
+ r = sd_bus_message_append(m, "a(stdo)", 1, "foo", 815ULL, 47.0, "/");
+ assert_se(r >= 0);
+
r = bus_message_seal(m, 4711, 0);
assert_se(r >= 0);
r = bus_message_seal(m, 4711, 0);
assert_se(r >= 0);
@@
-268,6
+274,13
@@
int main(int argc, char *argv[]) {
assert_se(r > 0);
assert_se(sz == 0);
assert_se(r > 0);
assert_se(sz == 0);
+ r = sd_bus_message_read(m, "a(stdo)", 1, &x, &u64, &dbl, &y);
+ assert_se(r > 0);
+ assert_se(streq(x, "foo"));
+ assert_se(u64 == 815ULL);
+ assert_se(fabs(dbl - 47.0) < 0.1);
+ assert_se(streq(y, "/"));
+
r = sd_bus_message_peek_type(m, NULL, NULL);
assert_se(r == 0);
r = sd_bus_message_peek_type(m, NULL, NULL);
assert_se(r == 0);