mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-08 22:45:43 +00:00
91 lines
3 KiB
Diff
91 lines
3 KiB
Diff
From 6cd37a5e59e01f4a2b3f02d9746b3e7417d424e6 Mon Sep 17 00:00:00 2001
|
|
From: Lennart Poettering <lennart@poettering.net>
|
|
Date: Fri, 23 Jan 2015 01:13:09 +0100
|
|
Subject: [PATCH] sd-bus: fix handling of double parameters in
|
|
sd_bus_message_append()
|
|
|
|
We really need to use va_arg() with the right type here as uint64_t and
|
|
double might have the same size, but are passed differently as
|
|
arguments.
|
|
---
|
|
src/libsystemd/sd-bus/bus-message.c | 11 +++++++++--
|
|
src/libsystemd/sd-bus/test-bus-marshal.c | 13 +++++++++++++
|
|
2 files changed, 22 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
|
|
index 23076d2..9ae65be 100644
|
|
--- a/src/libsystemd/sd-bus/bus-message.c
|
|
+++ b/src/libsystemd/sd-bus/bus-message.c
|
|
@@ -2350,8 +2350,7 @@ int bus_message_append_ap(
|
|
}
|
|
|
|
case SD_BUS_TYPE_INT64:
|
|
- case SD_BUS_TYPE_UINT64:
|
|
- case SD_BUS_TYPE_DOUBLE: {
|
|
+ case SD_BUS_TYPE_UINT64: {
|
|
uint64_t x;
|
|
|
|
x = va_arg(ap, uint64_t);
|
|
@@ -2359,6 +2358,14 @@ int bus_message_append_ap(
|
|
break;
|
|
}
|
|
|
|
+ case SD_BUS_TYPE_DOUBLE: {
|
|
+ double x;
|
|
+
|
|
+ x = va_arg(ap, double);
|
|
+ r = sd_bus_message_append_basic(m, *t, &x);
|
|
+ break;
|
|
+ }
|
|
+
|
|
case SD_BUS_TYPE_STRING:
|
|
case SD_BUS_TYPE_OBJECT_PATH:
|
|
case SD_BUS_TYPE_SIGNATURE: {
|
|
diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c
|
|
index 8cefc7a..d95a03c 100644
|
|
--- 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 <math.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;
|
|
+ double dbl;
|
|
+ uint64_t u64;
|
|
|
|
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(m, "a(stdo)", 1, "foo", 815ULL, 47.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);
|
|
|
|
+ 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);
|
|
|
|
--
|
|
2.3.0
|
|
|