From a63f9aad25e354f706c580a531d72a758d7906f7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 23 Aug 2019 11:29:32 +0200 Subject: [PATCH] shared/hash: implement nm_hash_obfuscate_ptr() as inline function instead of macro There is really no reason for this to be a macro. Our hash-related helpers (like nm_hash_update_val()) are macros because they do some shenigans to accept arguments of different (compile-time) types. But the arguments for nm_hash_obfuscate_ptr() are well known and expected of a certain form. Note that with "-O2" some quick testing shows that the compiler no longer inlines the function. But I guess that's fine, probably the compiler knows best anyway. --- shared/nm-glib-aux/nm-hash-utils.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index aa0a3d7c0a..5f70a544d5 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -311,15 +311,15 @@ gboolean nm_pdirect_equal (gconstpointer a, gconstpointer b); * * Note that there is a chance that two different pointer values hash to the same obfuscated * value. So beware of that when reviewing logs. However, such a collision is very unlikely. */ -#define nm_hash_obfuscate_ptr(static_seed, val) \ - ({ \ - NMHashState _h; \ - const void *_val_obf_ptr = (val); \ - \ - nm_hash_init (&_h, (static_seed)); \ - nm_hash_update_val (&_h, _val_obf_ptr); \ - nm_hash_complete_u64 (&_h); \ - }) +static inline guint64 +nm_hash_obfuscate_ptr (guint static_seed, gconstpointer val) +{ + NMHashState h; + + nm_hash_init (&h, static_seed); + nm_hash_update_val (&h, val); + return nm_hash_complete_u64 (&h); +} /* if you want to log obfuscated pointer for a certain context (like, NMPRuleManager * logging user-tags), then you are advised to use nm_hash_obfuscate_ptr() with your