diff options
author | Thomas Haller <thaller@redhat.com> | 2020-10-08 11:51:42 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-10-08 11:55:36 +0200 |
commit | 5b941666e9053348d51113b2fa8dd7e62e01f1ab (patch) | |
tree | bc71be0080863a8164ccae23521e469b45787856 | |
parent | 621ca03b334cbeee42080c35c27dc8056a91c8a0 (diff) | |
download | NetworkManager-5b941666e9053348d51113b2fa8dd7e62e01f1ab.tar.gz |
shared: add NM_HASH_OBFUSCATE_PTR_STR() helper macro
Contrary to NM_HASH_OBFUSCATE_PTR(), this allows to special case a %NULL
pointer. Also, it quotes the obfuscated value in square brackets.
-rw-r--r-- | shared/nm-glib-aux/nm-hash-utils.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-hash-utils.h b/shared/nm-glib-aux/nm-hash-utils.h index 1cfdcaf6e9..6028bb3d74 100644 --- a/shared/nm-glib-aux/nm-hash-utils.h +++ b/shared/nm-glib-aux/nm-hash-utils.h @@ -416,6 +416,14 @@ nm_hash_obfuscate_ptr(guint static_seed, gconstpointer val) * values in a global context. */ #define NM_HASH_OBFUSCATE_PTR(ptr) (nm_hash_obfuscate_ptr(1678382159u, ptr)) +#define NM_HASH_OBFUSCATE_PTR_STR(ptr, buf) \ + ({ \ + gconstpointer _ptr = (ptr); \ + \ + _ptr ? nm_sprintf_buf(buf, "[" NM_HASH_OBFUSCATE_PTR_FMT "]", NM_HASH_OBFUSCATE_PTR(_ptr)) \ + : "(null)"; \ + }) + static inline const char * nm_hash_obfuscated_ptr_str(gconstpointer ptr, char buf[static 17]) { |