From cafbca06e78d246df3ab15a6c9f8205c41fd9210 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 17 May 2014 20:25:14 +0200 Subject: [PATCH] Imported portableproplib-0.6.4. --- 3RDPARTY | 4 +- NEWS | 2 + lib/Makefile | 2 +- lib/portableproplib/prop_array.c | 11 ++-- lib/portableproplib/prop_array_util.c | 4 +- lib/portableproplib/prop_dictionary.c | 26 +++----- lib/portableproplib/prop_ingest.c | 4 +- lib/portableproplib/prop_number.c | 28 ++++----- lib/portableproplib/prop_object.c | 84 ++++++++++---------------- lib/portableproplib/prop_object_impl.h | 48 ++++++++++++++- lib/portableproplib/prop_string.c | 6 +- lib/portableproplib/rb.c | 2 +- 12 files changed, 117 insertions(+), 104 deletions(-) diff --git a/3RDPARTY b/3RDPARTY index d01c944d..52e8f798 100644 --- a/3RDPARTY +++ b/3RDPARTY @@ -17,5 +17,5 @@ internal use in the code: - libfetch-2.34 from NetBSD (pkgsrc/net/libfetch): lib/fetch -- portableproplib-0.6.3 (lib/portableproplib) from - http://code.google.com/p/portableproplib +- portableproplib-0.6.4 (lib/portableproplib) from + https://github.com/xtraeme/portableproplib diff --git a/NEWS b/NEWS index 54a632f3..515b8904 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ xbps-0.37 (???): + * Imported portable proplib 0.6.4 from https://github.com/xtraeme/portableproplib. + * Fixed a new issue with virtual packages, if a pkg provides a virtual package that is already installed but with lesser version, do not update to it unnecessarily (in some cases results in a crash). diff --git a/lib/Makefile b/lib/Makefile index 4675c122..5d5874c5 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -15,7 +15,7 @@ LIBPROP_OBJS += portableproplib/prop_array_util.o portableproplib/prop_number.o LIBPROP_OBJS += portableproplib/prop_dictionary_util.o portableproplib/prop_zlib.o LIBPROP_OBJS += portableproplib/prop_data.o LIBPROP_CPPFLAGS = -D_GNU_SOURCE -LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter +LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter -Wno-unused-but-set-variable LIBPROP_CFLAGS += -fvisibility=hidden # libfetch diff --git a/lib/portableproplib/prop_array.c b/lib/portableproplib/prop_array.c index 8df01669..5a4d82e0 100644 --- a/lib/portableproplib/prop_array.c +++ b/lib/portableproplib/prop_array.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_array.c,v 1.20 2008/08/11 05:54:21 christos Exp $ */ +/* $NetBSD: prop_array.c,v 1.21 2012/07/27 09:10:59 pooka Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -29,8 +29,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "prop_object_impl.h" +#include + #include struct _prop_array { @@ -107,8 +108,6 @@ _prop_array_free(prop_stack_t stack, prop_object_t *obj) return (_PROP_OBJECT_FREE_DONE); } - if (pa->pa_array == NULL) - return _PROP_OBJECT_FREE_DONE; po = pa->pa_array[pa->pa_count - 1]; _PROP_ASSERT(po != NULL); @@ -337,7 +336,7 @@ static prop_object_t _prop_array_iterator_next_object(void *v) { struct _prop_array_iterator *pai = v; - prop_array_t pa = pai->pai_base.pi_obj; + prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj; prop_object_t po; _PROP_ASSERT(prop_object_is_array(pa)); @@ -364,7 +363,7 @@ static void _prop_array_iterator_reset(void *v) { struct _prop_array_iterator *pai = v; - prop_array_t pa = pai->pai_base.pi_obj; + prop_array_t pa _PROP_ARG_UNUSED = pai->pai_base.pi_obj; _PROP_ASSERT(prop_object_is_array(pa)); diff --git a/lib/portableproplib/prop_array_util.c b/lib/portableproplib/prop_array_util.c index 6c086bd4..66f20c44 100644 --- a/lib/portableproplib/prop_array_util.c +++ b/lib/portableproplib/prop_array_util.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_array_util.c,v 1.2 2008/09/11 13:15:13 haad Exp $ */ +/* $NetBSD: prop_array_util.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -38,8 +38,8 @@ * exactly what we're doing here. */ +#include "prop_object_impl.h" /* hide kernel vs. not-kernel vs. standalone */ #include -#include "prop_object_impl.h" bool prop_array_get_bool(prop_array_t array, diff --git a/lib/portableproplib/prop_dictionary.c b/lib/portableproplib/prop_dictionary.c index 3ba001e5..715eb3ba 100644 --- a/lib/portableproplib/prop_dictionary.c +++ b/lib/portableproplib/prop_dictionary.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_dictionary.c,v 1.37 2011/04/20 19:40:00 martin Exp $ */ +/* $NetBSD: prop_dictionary.c,v 1.39 2013/10/18 18:26:20 martin Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -29,10 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "prop_object_impl.h" #include #include #include -#include "prop_object_impl.h" #include "prop_rb_impl.h" #include @@ -169,7 +169,7 @@ struct _prop_dictionary_iterator { static int /*ARGSUSED*/ -_prop_dict_keysym_rb_compare_nodes(void *ctx, +_prop_dict_keysym_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED, const void *n1, const void *n2) { const struct _prop_dictionary_keysym *pdk1 = n1; @@ -180,7 +180,7 @@ _prop_dict_keysym_rb_compare_nodes(void *ctx, static int /*ARGSUSED*/ -_prop_dict_keysym_rb_compare_key(void *ctx, +_prop_dict_keysym_rb_compare_key(void *ctx _PROP_ARG_UNUSED, const void *n, const void *v) { const struct _prop_dictionary_keysym *pdk = n; @@ -278,10 +278,7 @@ _prop_dict_keysym_equals(prop_object_t v1, prop_object_t v2, static prop_dictionary_keysym_t _prop_dict_keysym_alloc(const char *key) { -#ifdef DEBUG - prop_dictionary_keysym_t rpdk; -#endif - prop_dictionary_keysym_t opdk, pdk; + prop_dictionary_keysym_t opdk, pdk, rpdk; size_t size; _PROP_ONCE_RUN(_prop_dict_init_once, _prop_dict_init); @@ -334,12 +331,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); + return (rpdk); } static _prop_object_free_rv_t @@ -364,8 +359,6 @@ _prop_dictionary_free(prop_stack_t stack, prop_object_t *obj) return (_PROP_OBJECT_FREE_DONE); } - if (pd->pd_array == NULL) - return _PROP_OBJECT_FREE_DONE; po = pd->pd_array[pd->pd_count - 1].pde_objref; _PROP_ASSERT(po != NULL); @@ -631,7 +624,7 @@ static prop_object_t _prop_dictionary_iterator_next_object(void *v) { struct _prop_dictionary_iterator *pdi = v; - prop_dictionary_t pd = pdi->pdi_base.pi_obj; + prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj; prop_dictionary_keysym_t pdk; _PROP_ASSERT(prop_object_is_dictionary(pd)); @@ -658,7 +651,7 @@ static void _prop_dictionary_iterator_reset(void *v) { struct _prop_dictionary_iterator *pdi = v; - prop_dictionary_t pd = pdi->pdi_base.pi_obj; + prop_dictionary_t pd _PROP_ARG_UNUSED = pdi->pdi_base.pi_obj; _PROP_RWLOCK_RDLOCK(pd->pd_rwlock); _prop_dictionary_iterator_reset_locked(pdi); @@ -1391,8 +1384,7 @@ prop_dictionary_externalize_to_file(prop_dictionary_t dict, const char *fname) xml = prop_dictionary_externalize(dict); if (xml == NULL) return (false); - rv = _prop_object_externalize_write_file(fname, xml, strlen(xml), - false); + rv = _prop_object_externalize_write_file(fname, xml, strlen(xml), false); if (rv == false) save_errno = errno; _PROP_FREE(xml, M_TEMP); diff --git a/lib/portableproplib/prop_ingest.c b/lib/portableproplib/prop_ingest.c index 823d2c6c..9d161b57 100644 --- a/lib/portableproplib/prop_ingest.c +++ b/lib/portableproplib/prop_ingest.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_ingest.c,v 1.3 2008/04/28 20:22:53 martin Exp $ */ +/* $NetBSD: prop_ingest.c,v 1.4 2012/07/27 09:10:59 pooka Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -29,8 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include #include "prop_object_impl.h" +#include struct _prop_ingest_context { prop_ingest_error_t pic_error; diff --git a/lib/portableproplib/prop_number.c b/lib/portableproplib/prop_number.c index 81f53892..daf035c7 100644 --- a/lib/portableproplib/prop_number.c +++ b/lib/portableproplib/prop_number.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_number.c,v 1.23 2010/09/24 22:51:52 rmind Exp $ */ +/* $NetBSD: prop_number.c,v 1.26 2014/03/26 18:12:46 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -112,7 +112,7 @@ _prop_number_compare_values(const struct _prop_number_value *pnv1, static int /*ARGSUSED*/ -_prop_number_rb_compare_nodes(void *ctx, +_prop_number_rb_compare_nodes(void *ctx _PROP_ARG_UNUSED, const void *n1, const void *n2) { const struct _prop_number *pn1 = n1; @@ -123,7 +123,8 @@ _prop_number_rb_compare_nodes(void *ctx, static int /*ARGSUSED*/ -_prop_number_rb_compare_key(void *ctx, const void *n, const void *v) +_prop_number_rb_compare_key(void *ctx _PROP_ARG_UNUSED, + const void *n, const void *v) { const struct _prop_number *pn = n; const struct _prop_number_value *pnv = v; @@ -187,15 +188,15 @@ _prop_number_externalize(struct _prop_object_externalize_context *ctx, char tmpstr[32]; /* - * For the record: - * the original NetBSD implementation used hexadecimal for unsigned - * numbers, but in the portable proplib we changed it to be human - * readable (base 10). + * For unsigned numbers, we output in hex. For signed numbers, + * we output in decimal. */ if (pn->pn_value.pnv_is_unsigned) - sprintf(tmpstr, "%" PRIu64, pn->pn_value.pnv_unsigned); + snprintf(tmpstr, sizeof(tmpstr), "%" PRIu64, + pn->pn_value.pnv_unsigned); else - sprintf(tmpstr, "%" PRIi64, pn->pn_value.pnv_signed); + snprintf(tmpstr, sizeof(tmpstr), "%" PRIi64, + pn->pn_value.pnv_signed); if (_prop_object_externalize_start_tag(ctx, "integer") == false || _prop_object_externalize_append_cstring(ctx, tmpstr) == false || @@ -264,10 +265,7 @@ _prop_number_equals(prop_object_t v1, prop_object_t v2, static prop_number_t _prop_number_alloc(const struct _prop_number_value *pnv) { -#ifdef DEBUG - prop_number_t rpn; -#endif - prop_number_t opn, pn; + prop_number_t opn, pn, rpn; _PROP_ONCE_RUN(_prop_number_init_once, _prop_number_init); @@ -308,12 +306,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); + return (rpn); } /* diff --git a/lib/portableproplib/prop_object.c b/lib/portableproplib/prop_object.c index 05dc256a..181d3f5b 100644 --- a/lib/portableproplib/prop_object.c +++ b/lib/portableproplib/prop_object.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_object.c,v 1.23 2008/11/30 00:17:07 haad Exp $ */ +/* $NetBSD: prop_object.c,v 1.29 2013/10/18 18:26:20 martin Exp $ */ /*- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc. @@ -29,10 +29,16 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include "compat.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include #include "prop_object_impl.h" +#include + +#ifdef _PROP_NEED_REFCNT_MTX +static pthread_mutex_t _prop_refcnt_mtx = PTHREAD_MUTEX_INITIALIZER; +#endif /* _PROP_NEED_REFCNT_MTX */ #include #include @@ -40,7 +46,6 @@ #include #include #include - #include /* @@ -63,7 +68,7 @@ _prop_object_init(struct _prop_object *po, const struct _prop_object_type *pot) */ /*ARGSUSED*/ void -_prop_object_fini(struct _prop_object *po) +_prop_object_fini(struct _prop_object *po _PROP_ARG_UNUSED) { /* Nothing to do, currently. */ } @@ -252,10 +257,8 @@ _prop_object_externalize_footer(struct _prop_object_externalize_context *ctx) { if (_prop_object_externalize_end_tag(ctx, "plist") == false || - _prop_object_externalize_append_char(ctx, '\0') == false) { - free(ctx->poec_buf); + _prop_object_externalize_append_char(ctx, '\0') == false) return (false); - } return (true); } @@ -602,7 +605,7 @@ match_start: poi->poi_taglen)) break; } - if (poi == NULL) { + if ((poi == NULL) || (poi->poi_tag == NULL)) { while (_prop_stack_pop(&stack, &obj, &iter, &data, NULL)) { iter_func = (prop_object_internalizer_continue_t)iter; (*iter_func)(&stack, &obj, ctx, data, NULL); @@ -831,11 +834,14 @@ _prop_object_externalize_write_file(const char *fname, const char *xml, * and create the temporary file. */ _prop_object_externalize_file_dirname(fname, tname); - - if (strlcat(tname, "/.plistXXXXXX", sizeof(tname)) >= sizeof(tname)) { +#define PLISTTMP "/.plistXXXXXX" + if (strlen(tname) + strlen(PLISTTMP) >= sizeof(tname)) { errno = ENAMETOOLONG; return (false); } + strcat(tname, PLISTTMP); +#undef PLISTTMP + if ((fd = mkstemp(tname)) == -1) return (false); @@ -869,6 +875,7 @@ _prop_object_externalize_write_file(const char *fname, const char *xml, (void)gzclose(gzf); else (void)close(fd); + fd = -1; if (rename(tname, fname) == -1) @@ -970,24 +977,6 @@ _prop_object_internalize_unmap_file( _PROP_FREE(mf, M_TEMP); } -/* - * Retain / release serialization -- - * - * Eventually we would like to use atomic operations. But until we have - * an MI API for them that is common to userland and the kernel, we will - * use a lock instead. - * - * We use a single global mutex for all serialization. In the kernel, because - * we are still under a biglock, this will basically never contend (properties - * cannot be manipulated at interrupt level). In userland, this will cost - * nothing for single-threaded programs. For multi-threaded programs, there - * could be contention, but it probably won't cost that much unless the program - * makes heavy use of property lists. - */ -_PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex) -#define _PROP_REFCNT_LOCK() _PROP_MUTEX_LOCK(_prop_refcnt_mutex) -#define _PROP_REFCNT_UNLOCK() _PROP_MUTEX_UNLOCK(_prop_refcnt_mutex) - /* * prop_object_retain -- * Increment the reference count on an object. @@ -995,18 +984,11 @@ _PROP_MUTEX_DECL_STATIC(_prop_refcnt_mutex) void prop_object_retain(prop_object_t obj) { -#ifdef DEBUG - uint32_t ocnt; -#endif struct _prop_object *po = obj; + uint32_t ncnt _PROP_ARG_UNUSED; - _PROP_REFCNT_LOCK(); - po->po_refcnt++; -#ifdef DEBUG - ocnt = po->po_refcnt; - _PROP_ASSERT(ocnt != 0xffffffffU); -#endif - _PROP_REFCNT_UNLOCK(); + _PROP_ATOMIC_INC32_NV(&po->po_refcnt, ncnt); + _PROP_ASSERT(ncnt != 0); } /* @@ -1036,11 +1018,11 @@ prop_object_release_emergency(prop_object_t obj) /* Save pointerto unlock function */ unlock = po->po_type->pot_unlock; - _PROP_REFCNT_LOCK(); - ocnt = po->po_refcnt--; - _PROP_REFCNT_UNLOCK(); - + /* Dance a bit to make sure we always get the non-racy ocnt */ + _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt); + ocnt++; _PROP_ASSERT(ocnt != 0); + if (ocnt != 1) { if (unlock != NULL) unlock(); @@ -1059,9 +1041,7 @@ prop_object_release_emergency(prop_object_t obj) unlock(); parent = po; - _PROP_REFCNT_LOCK(); - ++po->po_refcnt; - _PROP_REFCNT_UNLOCK(); + _PROP_ATOMIC_INC32(&po->po_refcnt); } _PROP_ASSERT(parent); /* One object was just freed. */ @@ -1098,11 +1078,10 @@ prop_object_release(prop_object_t obj) /* Save pointer to object unlock function */ unlock = po->po_type->pot_unlock; - _PROP_REFCNT_LOCK(); - ocnt = po->po_refcnt--; - _PROP_REFCNT_UNLOCK(); - + _PROP_ATOMIC_DEC32_NV(&po->po_refcnt, ocnt); + ocnt++; _PROP_ASSERT(ocnt != 0); + if (ocnt != 1) { ret = 0; if (unlock != NULL) @@ -1118,9 +1097,7 @@ prop_object_release(prop_object_t obj) if (ret == _PROP_OBJECT_FREE_DONE) break; - _PROP_REFCNT_LOCK(); - ++po->po_refcnt; - _PROP_REFCNT_UNLOCK(); + _PROP_ATOMIC_INC32(&po->po_refcnt); } while (ret == _PROP_OBJECT_FREE_RECURSE); if (ret == _PROP_OBJECT_FREE_FAILED) prop_object_release_emergency(obj); @@ -1187,6 +1164,7 @@ prop_object_equals_with_error(prop_object_t obj1, prop_object_t obj2, &stored_pointer1, &stored_pointer2)) return true; po1 = obj1; + po2 = obj2; goto continue_subtree; } _PROP_ASSERT(ret == _PROP_OBJECT_EQUALS_RECURSE); diff --git a/lib/portableproplib/prop_object_impl.h b/lib/portableproplib/prop_object_impl.h index 65b1739a..47dcf81b 100644 --- a/lib/portableproplib/prop_object_impl.h +++ b/lib/portableproplib/prop_object_impl.h @@ -1,4 +1,4 @@ -/* $NetBSD: prop_object_impl.h,v 1.30 2009/09/13 18:45:10 pooka Exp $ */ +/* $NetBSD: prop_object_impl.h,v 1.31 2012/07/27 09:10:59 pooka Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -224,6 +224,15 @@ struct _prop_object_iterator { uint32_t pi_version; }; +#define _PROP_NOTHREAD_ONCE_DECL(x) static bool x = false; +#define _PROP_NOTHREAD_ONCE_RUN(x,f) \ + do { \ + if ((x) == false) { \ + f(); \ + x = true; \ + } \ + } while (/*CONSTCOND*/0) + /* * proplib in user space... */ @@ -246,6 +255,8 @@ struct _prop_object_iterator { #define _PROP_POOL_INIT(p, s, d) static const size_t p = s; +#define _PROP_MALLOC_DEFINE(t, s, l) /* nothing */ + /* * Use pthread mutexes everywhere else. */ @@ -266,4 +277,39 @@ struct _prop_object_iterator { static pthread_once_t x = PTHREAD_ONCE_INIT; #define _PROP_ONCE_RUN(x,f) pthread_once(&(x),(void(*)(void))f) +#define _PROP_NEED_REFCNT_MTX + +#define _PROP_ATOMIC_INC32(x) \ +do { \ + pthread_mutex_lock(&_prop_refcnt_mtx); \ + (*(x))++; \ + pthread_mutex_unlock(&_prop_refcnt_mtx); \ +} while (/*CONSTCOND*/0) + +#define _PROP_ATOMIC_DEC32(x) \ +do { \ + pthread_mutex_lock(&_prop_refcnt_mtx); \ + (*(x))--; \ + pthread_mutex_unlock(&_prop_refcnt_mtx); \ +} while (/*CONSTCOND*/0) + +#define _PROP_ATOMIC_INC32_NV(x, v) \ +do { \ + pthread_mutex_lock(&_prop_refcnt_mtx); \ + v = ++(*(x)); \ + pthread_mutex_unlock(&_prop_refcnt_mtx); \ +} while (/*CONSTCOND*/0) + +#define _PROP_ATOMIC_DEC32_NV(x, v) \ +do { \ + pthread_mutex_lock(&_prop_refcnt_mtx); \ + v = --(*(x)); \ + pthread_mutex_unlock(&_prop_refcnt_mtx); \ +} while (/*CONSTCOND*/0) + +/* + * Language features. + */ +#define _PROP_ARG_UNUSED /* delete */ + #endif /* _PROPLIB_PROP_OBJECT_IMPL_H_ */ diff --git a/lib/portableproplib/prop_string.c b/lib/portableproplib/prop_string.c index 6daddbd6..417c8791 100644 --- a/lib/portableproplib/prop_string.c +++ b/lib/portableproplib/prop_string.c @@ -1,4 +1,4 @@ -/* $NetBSD: prop_string.c,v 1.11 2008/08/03 04:00:12 thorpej Exp $ */ +/* $NetBSD: prop_string.c,v 1.12 2014/03/26 18:12:46 christos Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -337,7 +337,7 @@ prop_string_append(prop_string_t dst, prop_string_t src) cp = _PROP_MALLOC(len + 1, M_PROP_STRING); if (cp == NULL) return (false); - sprintf(cp, "%s%s", prop_string_contents(dst), + snprintf(cp, len + 1, "%s%s", prop_string_contents(dst), prop_string_contents(src)); ocp = dst->ps_mutable; dst->ps_mutable = cp; @@ -371,7 +371,7 @@ prop_string_append_cstring(prop_string_t dst, const char *src) cp = _PROP_MALLOC(len + 1, M_PROP_STRING); if (cp == NULL) return (false); - sprintf(cp, "%s%s", prop_string_contents(dst), src); + snprintf(cp, len + 1, "%s%s", prop_string_contents(dst), src); ocp = dst->ps_mutable; dst->ps_mutable = cp; dst->ps_size = len; diff --git a/lib/portableproplib/rb.c b/lib/portableproplib/rb.c index 8be152a2..27cead62 100644 --- a/lib/portableproplib/rb.c +++ b/lib/portableproplib/rb.c @@ -69,7 +69,7 @@ rb_tree_init(struct rb_tree *rbt, const rb_tree_ops_t *ops) { rbt->rbt_ops = ops; - *((const struct rb_node **)&rbt->rbt_root) = RB_SENTINEL_NODE; + rbt->rbt_root = RB_SENTINEL_NODE; RB_TAILQ_INIT(&rbt->rbt_nodes); #ifndef RBSMALL rbt->rbt_minmax[RB_DIR_LEFT] = rbt->rbt_root; /* minimum node */