From e23c64bc846fe6feb6d0f5715b4130cf0bb129f0 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 6 Dec 2013 11:54:34 +0100 Subject: [PATCH] lib/portableproplib: fixes to allow building with NDEBUG (assert()s disabled). --- lib/portableproplib/prop_dictionary.c | 7 ++++++- lib/portableproplib/prop_number.c | 7 ++++++- lib/portableproplib/prop_object.c | 12 ++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/portableproplib/prop_dictionary.c b/lib/portableproplib/prop_dictionary.c index 8baba9cb..3ba001e5 100644 --- a/lib/portableproplib/prop_dictionary.c +++ b/lib/portableproplib/prop_dictionary.c @@ -278,7 +278,10 @@ _prop_dict_keysym_equals(prop_object_t v1, prop_object_t v2, static prop_dictionary_keysym_t _prop_dict_keysym_alloc(const char *key) { - prop_dictionary_keysym_t opdk, pdk, rpdk; +#ifdef DEBUG + prop_dictionary_keysym_t rpdk; +#endif + prop_dictionary_keysym_t opdk, pdk; size_t size; _PROP_ONCE_RUN(_prop_dict_init_once, _prop_dict_init); @@ -331,8 +334,10 @@ _prop_dict_keysym_alloc(const char *key) _prop_dict_keysym_put(pdk); return (opdk); } +#ifdef DEBUG rpdk = _prop_rb_tree_insert_node(&_prop_dict_keysym_tree, pdk); _PROP_ASSERT(rpdk == pdk); +#endif _PROP_MUTEX_UNLOCK(_prop_dict_keysym_tree_mutex); return (pdk); } diff --git a/lib/portableproplib/prop_number.c b/lib/portableproplib/prop_number.c index ab3013aa..81f53892 100644 --- a/lib/portableproplib/prop_number.c +++ b/lib/portableproplib/prop_number.c @@ -264,7 +264,10 @@ _prop_number_equals(prop_object_t v1, prop_object_t v2, static prop_number_t _prop_number_alloc(const struct _prop_number_value *pnv) { - prop_number_t opn, pn, rpn; +#ifdef DEBUG + prop_number_t rpn; +#endif + prop_number_t opn, pn; _PROP_ONCE_RUN(_prop_number_init_once, _prop_number_init); @@ -305,8 +308,10 @@ _prop_number_alloc(const struct _prop_number_value *pnv) _PROP_POOL_PUT(_prop_number_pool, pn); return (opn); } +#ifdef DEBUG rpn = _prop_rb_tree_insert_node(&_prop_number_tree, pn); _PROP_ASSERT(rpn == pn); +#endif _PROP_MUTEX_UNLOCK(_prop_number_tree_mutex); return (pn); } diff --git a/lib/portableproplib/prop_object.c b/lib/portableproplib/prop_object.c index 008fbc5a..bc1aaa28 100644 --- a/lib/portableproplib/prop_object.c +++ b/lib/portableproplib/prop_object.c @@ -997,14 +997,18 @@ _PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex) void prop_object_retain(prop_object_t obj) { - struct _prop_object *po = obj; +#ifdef DEBUG uint32_t ocnt; +#endif + struct _prop_object *po = obj; _PROP_REFCNT_LOCK(); - ocnt = po->po_refcnt++; - _PROP_REFCNT_UNLOCK(); - + po->po_refcnt++; +#ifdef DEBUG + ocnt = po->po_refcnt; _PROP_ASSERT(ocnt != 0xffffffffU); +#endif + _PROP_REFCNT_UNLOCK(); } /*