diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-09-18 15:27:50 +0200 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-09-30 18:36:23 +0100 |
commit | e9a3dd76576142b78dd1abc8aafb7221dbc40918 (patch) | |
tree | f8cac0b205935f0d12faee8981aab5dde90b961c /tools/dbus-print-message.c | |
parent | 8b7f332bca062899c3d82e5ad18a31cf26fcbb7c (diff) | |
download | dbus-e9a3dd76576142b78dd1abc8aafb7221dbc40918.tar.gz |
Use C99 standard PRI*64 for printing 64 bit integers
Use the standard C99 PRI*64 macros instead of checking for specific GNU
libc version. We also specifically check for windows which does not have
proper C99 support.
This fixes printing of int64 on non-GNU 32 bit systems (like musl libc).
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92043
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[smcv: fix extra % in the Windows fallbacks; include <inttypes.h> where needed]
Diffstat (limited to 'tools/dbus-print-message.c')
-rw-r--r-- | tools/dbus-print-message.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index 80c96986..b747e877 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -39,6 +39,19 @@ #include "tool-common.h" +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#if defined(DBUS_WIN) +#if !defined(PRId64) +#define PRId64 "I64d" +#endif +#if !defined(PRIu64) +#define PRIu64 "I64u" +#endif +#endif + static const char* type_to_name (int message_type) { @@ -384,11 +397,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth) { dbus_int64_t val; dbus_message_iter_get_basic (iter, &val); -#ifdef DBUS_INT64_PRINTF_MODIFIER - printf ("int64 %" DBUS_INT64_PRINTF_MODIFIER "d\n", val); -#else - printf ("int64 (omitted)\n"); -#endif + printf ("int64 %" PRId64 "\n", val); break; } @@ -396,11 +405,7 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth) { dbus_uint64_t val; dbus_message_iter_get_basic (iter, &val); -#ifdef DBUS_INT64_PRINTF_MODIFIER - printf ("uint64 %" DBUS_INT64_PRINTF_MODIFIER "u\n", val); -#else - printf ("uint64 (omitted)\n"); -#endif + printf ("uint64 %" PRIu64 "\n", val); break; } |