diff options
author | Thomas Haller <thaller@redhat.com> | 2019-08-23 11:29:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-08-23 11:48:58 +0200 |
commit | a63f9aad25e354f706c580a531d72a758d7906f7 (patch) | |
tree | 6ed2466cd3a0b05fdb238c1b914b893c67240209 | |
parent | aa100d89a41544c3d9caf5d91d7a28caa95d7131 (diff) | |
download | NetworkManager-a63f9aad25e354f706c580a531d72a758d7906f7.tar.gz |
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.
-rw-r--r-- | shared/nm-glib-aux/nm-hash-utils.h | 18 |
1 files 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 |