From 2f0e9ab1ef271132b8b7b1af25e23ac7bb0720c8 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 29 Nov 2016 16:51:58 +0100 Subject: refcount: return pointer to the structure instead of a counter There are no real users of the counter. It was thought of a handy tool to track and debug refcounting, but it is not used at all. Some parts of the code would benefit from a pointer getting returned instead. BUG: 1399780 Change-Id: I97e52c48420fed61be942ea27ff4849b803eed12 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/15971 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Xavier Hernandez Reviewed-by: Kaleb KEITHLEY --- xlators/nfs/server/src/auth-cache.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'xlators/nfs/server/src/auth-cache.c') diff --git a/xlators/nfs/server/src/auth-cache.c b/xlators/nfs/server/src/auth-cache.c index 71e300ddf11..2b37a7f06bd 100644 --- a/xlators/nfs/server/src/auth-cache.c +++ b/xlators/nfs/server/src/auth-cache.c @@ -145,8 +145,9 @@ auth_cache_add (struct auth_cache *cache, char *hashkey, GF_VALIDATE_OR_GOTO (GF_NFS, cache, out); GF_VALIDATE_OR_GOTO (GF_NFS, cache->cache_dict, out); - ret = GF_REF_GET (entry); - if (ret == 0) { + /* FIXME: entry is passed as parameter, this can never fail? */ + entry = GF_REF_GET (entry); + if (!entry) { /* entry does not have any references */ ret = -1; goto out; @@ -221,8 +222,9 @@ auth_cache_get (struct auth_cache *cache, char *hashkey, if (!entry_data) goto unlock; - lookup_res = (struct auth_cache_entry *)(entry_data->data); - if (GF_REF_GET (lookup_res) == 0) { + /* FIXME: this is dangerous use of entry_data */ + lookup_res = GF_REF_GET ((struct auth_cache_entry *) entry_data->data); + if (lookup_res == NULL) { /* entry has been free'd */ ret = ENTRY_EXPIRED; goto unlock; -- cgit