From a1d60fe4e9ba46e2f472170e65043f5735af1fd5 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 14 Mar 2017 15:38:39 +0100 Subject: refcount: correct the return value of GF_REF_PUT() It is documented that GF_REF_PUT() returns a 0 in case the call resulted in free'ing the structure. However the implementations did not have a return value, so nothing can actually use it. Change-Id: Ic57091f5ddd7e0b80929dc335a5b6d37f5fe1b2e BUG: 1433405 Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/16910 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Xavier Hernandez Reviewed-by: Jeff Darcy Reviewed-by: Kaleb KEITHLEY --- libglusterfs/src/refcount.c | 8 ++++++-- libglusterfs/src/refcount.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/refcount.c b/libglusterfs/src/refcount.c index 9d33b733cf0..5787da290bb 100644 --- a/libglusterfs/src/refcount.c +++ b/libglusterfs/src/refcount.c @@ -30,7 +30,7 @@ _gf_ref_get (gf_ref_t *ref) return cnt ? ref->data : NULL; } -void +unsigned int _gf_ref_put (gf_ref_t *ref) { unsigned int cnt = __sync_fetch_and_sub (&ref->cnt, 1); @@ -45,6 +45,8 @@ _gf_ref_put (gf_ref_t *ref) if (cnt == 1 && ref->release) ref->release (ref->data); + + return (cnt != 1); } #else @@ -67,7 +69,7 @@ _gf_ref_get (gf_ref_t *ref) return cnt ? ref->data : NULL; } -void +unsigned int _gf_ref_put (gf_ref_t *ref) { unsigned int cnt = 0; @@ -86,6 +88,8 @@ _gf_ref_put (gf_ref_t *ref) if (release && ref->release) ref->release (ref->data); + + return !release; } #endif /* REFCOUNT_NEEDS_LOCK */ diff --git a/libglusterfs/src/refcount.h b/libglusterfs/src/refcount.h index 583b75cf8c2..4ae37fecbfe 100644 --- a/libglusterfs/src/refcount.h +++ b/libglusterfs/src/refcount.h @@ -50,7 +50,7 @@ _gf_ref_get (gf_ref_t *ref); * @return: greater then 0 when there are still references, 0 when cleanup * should be done, gf_ref_release_t is called on cleanup */ -void +unsigned int _gf_ref_put (gf_ref_t *ref); /* _gf_ref_init -- initalize an embedded refcount object -- cgit