summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-01-16 15:44:11 +0100
committerThomas Haller <thaller@redhat.com>2019-01-16 15:45:43 +0100
commite7e0100062aa404d82181c8b509af6ff1beb5f65 (patch)
tree7265821af3d2c1e739154dd45c90398849ab2b1d
parent3409a9750cd2d3c5ba4b6960a6864410eca21cca (diff)
downloadNetworkManager-e7e0100062aa404d82181c8b509af6ff1beb5f65.tar.gz
shared: fix generic selection of integers in nm_strdup_int()
This fixes a test error, which aims to convert "unsigned long int" type, but the generic type may not have been covered. Don't select based on the gint32-like typedefs, but on the basic C integer types. Fixes: 8c2d58b23746babf021e546449ea7b1c7549f6ba https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/108
-rw-r--r--shared/nm-utils/nm-shared-utils.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h
index 66d2b84e8e..8106371d0a 100644
--- a/shared/nm-utils/nm-shared-utils.h
+++ b/shared/nm-utils/nm-shared-utils.h
@@ -304,17 +304,19 @@ _nm_strndup_a_step (char *s, const char *str, gsize len)
#if _NM_CC_SUPPORT_GENERIC
#define nm_strdup_int(val) \
_Generic ((val), \
- char: g_strdup_printf ("%d", (int) (val)), \
+ char: g_strdup_printf ("%d", (int) (val)), \
\
- gint8: g_strdup_printf ("%d", (int) (val)), \
- gint16: g_strdup_printf ("%d", (int) (val)), \
- gint32: g_strdup_printf ("%d", (int) (val)), \
- gint64: g_strdup_printf ("%"G_GINT64_FORMAT, (gint64) (val)), \
+ signed char: g_strdup_printf ("%d", (signed) (val)), \
+ signed short: g_strdup_printf ("%d", (signed) (val)), \
+ signed: g_strdup_printf ("%d", (signed) (val)), \
+ signed long: g_strdup_printf ("%ld", (signed long) (val)), \
+ signed long long: g_strdup_printf ("%lld", (signed long long) (val)), \
\
- guint8: g_strdup_printf ("%u", (guint) (val)), \
- guint16: g_strdup_printf ("%u", (guint) (val)), \
- guint32: g_strdup_printf ("%u", (guint) (val)), \
- guint64: g_strdup_printf ("%"G_GUINT64_FORMAT, (guint64) (val)) \
+ unsigned char: g_strdup_printf ("%u", (unsigned) (val)), \
+ unsigned short: g_strdup_printf ("%u", (unsigned) (val)), \
+ unsigned: g_strdup_printf ("%u", (unsigned) (val)), \
+ unsigned long: g_strdup_printf ("%lu", (unsigned long) (val)), \
+ unsigned long long: g_strdup_printf ("%llu", (unsigned long long) (val)) \
)
#else
#define nm_strdup_int(val) \