From 2c37a3fb1ed4faccf60f06b81b1ca2a7f4fa6f5e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 27 Feb 2019 16:54:43 +0100 Subject: [PATCH] platform: add NULL check in inline nmp_object_unref() function This allows the compiler to see that this function does nothing for %NULL. That is not so unusual, as we use nm_auto_nmpobj to free objects. Often the compiler can see that these pointers are %NULL. --- src/platform/nmp-object.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/nmp-object.h b/src/platform/nmp-object.h index 7d64b094c..5c5b510ad 100644 --- a/src/platform/nmp-object.h +++ b/src/platform/nmp-object.h @@ -632,9 +632,11 @@ nmp_object_ref (const NMPObject *obj) static inline void nmp_object_unref (const NMPObject *obj) { - nm_assert (!obj || NMP_OBJECT_IS_VALID (obj)); + if (obj) { + nm_assert (NMP_OBJECT_IS_VALID (obj)); - nm_dedup_multi_obj_unref ((const NMDedupMultiObj *) obj); + nm_dedup_multi_obj_unref ((const NMDedupMultiObj *) obj); + } } #define nm_clear_nmp_object(ptr) \