From 443859f71fb134e2896cfd8dfac31bfc912867db Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 27 Jul 2020 15:17:54 +0200 Subject: [PATCH] shared: add NM_CMP_DIRECT_UNSAFE() macro --- shared/nm-glib-aux/nm-shared-utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index bff62b3226..d44321d34e 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -262,6 +262,12 @@ gboolean nm_utils_ipaddr_is_normalized (int addr_family, return (_a < _b) ? -1 : 1; \ } G_STMT_END +#define NM_CMP_DIRECT_UNSAFE(a, b) \ + G_STMT_START { \ + if ((a) != (b)) \ + return ((a) < (b)) ? -1 : 1; \ + } G_STMT_END + /* In the general case, direct pointer comparison is undefined behavior in C. * Avoid that by casting pointers to void* and then to uintptr_t. This comparison * is not really meaningful, except that it provides some kind of stable sort order