Blob Blame History Raw
From e4561754a2ca05cab143d2fb3f3102fad9ed8b94 Mon Sep 17 00:00:00 2001
From: Niels de Vos <ndevos@redhat.com>
Date: Tue, 16 May 2017 19:46:04 +0200
Subject: [PATCH 446/473] refcount: typecast function for calling on free

All of the functions called to free the refcounted structure are doing a
typecast from (void*) to their own type taht is being free'd. This
really is not needed and the refcount interface is made a little simpler
without the requirement of typecasting.

With this small improvement in the API, all callers are updated too.

Cherry picked from commit f2ca301bd741e3e3f076cd3f72fcd377bcef2a1a:
> Change-Id: I32473b6d1799f62861d4b2d78ea30c09e6c80ab1
> BUG: 1416889
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
> Reviewed-on: https://review.gluster.org/16471
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>

There has been a slight omission in the backport of change
I19d225b39aaa272d9005ba7adc3104c3764f1572. This missing backport results
in compiler warnings like:

    ctx.c: In function 'glusterfs_ctx_tw_get':
    ctx.c:72:25: warning: passing argument 2 of '_gf_ref_init' from incompatible pointer type [enabled by default]
                             GF_REF_INIT (ctx_tw, glusterfs_ctx_tw_destroy);

Change-Id: I32473b6d1799f62861d4b2d78ea30c09e6c80ab1
BUG: 1450336
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/106357
Reviewed-by: Poornima Gurusiddaiah <pgurusid@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 api/src/glfs.c                                    | 10 +++-------
 libglusterfs/src/refcount.h                       |  2 +-
 rpc/rpc-transport/socket/src/socket.c             |  6 ++----
 xlators/cluster/dht/src/dht-helper.c              |  9 ++-------
 xlators/features/marker/src/marker-quota-helper.c |  6 ++----
 xlators/features/marker/src/marker-quota-helper.h |  3 ---
 6 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/api/src/glfs.c b/api/src/glfs.c
index 62441c9..253b98d 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -540,16 +540,12 @@ pub_glfs_from_glfd (struct glfs_fd *glfd)
 
 GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_from_glfd, 3.4.0);
 
-void
-glfs_fd_destroy (void *data)
+static void
+glfs_fd_destroy (struct glfs_fd *glfd)
 {
-        struct glfs_fd  *glfd = NULL;
-
-        if (!data)
+        if (!glfd)
                 return;
 
-        glfd = (struct glfs_fd *)data;
-
         glfs_lock (glfd->fs, _gf_true);
         {
                 list_del_init (&glfd->openfds);
diff --git a/libglusterfs/src/refcount.h b/libglusterfs/src/refcount.h
index db9432a..583b75c 100644
--- a/libglusterfs/src/refcount.h
+++ b/libglusterfs/src/refcount.h
@@ -84,7 +84,7 @@ _gf_ref_init (gf_ref_t *ref, gf_ref_release_t release, void *data);
  *
  * Sets the refcount to 1.
  */
-#define GF_REF_INIT(p, d)   _gf_ref_init (&(p)->_ref, d, p)
+#define GF_REF_INIT(p, d)   _gf_ref_init (&(p)->_ref, (gf_ref_release_t) d, p)
 
 /* GF_REF_GET -- increase the refcount of a GF_REF_DECL structure
  *
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index f64e2f0..07cf7a6 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -3929,11 +3929,9 @@ init_openssl_mt (void)
         SSL_load_error_strings();
 }
 
-void
-socket_poller_mayday (void *data)
+static void
+socket_poller_mayday (socket_private_t *priv)
 {
-        socket_private_t *priv = (socket_private_t *)data;
-
         if (priv == NULL)
                 return;
 
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 255c082..c22f700 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -15,15 +15,10 @@
 #include "dht-helper.h"
 
 
-void
-dht_free_fd_ctx (void *data)
+static void
+dht_free_fd_ctx (dht_fd_ctx_t *fd_ctx)
 {
-        dht_fd_ctx_t *fd_ctx = NULL;
-
-        fd_ctx = (dht_fd_ctx_t *)data;
         GF_FREE (fd_ctx);
-
-        return;
 }
 
 
diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c
index 1fed9df..e3e218f 100644
--- a/xlators/features/marker/src/marker-quota-helper.c
+++ b/xlators/features/marker/src/marker-quota-helper.c
@@ -146,11 +146,9 @@ out:
         return ctx;
 }
 
-void
-mq_contri_fini (void *data)
+static void
+mq_contri_fini (inode_contribution_t *contri)
 {
-        inode_contribution_t *contri = data;
-
         LOCK_DESTROY (&contri->lock);
         GF_FREE (contri);
 }
diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h
index bf417aa..444ba7c 100644
--- a/xlators/features/marker/src/marker-quota-helper.h
+++ b/xlators/features/marker/src/marker-quota-helper.h
@@ -66,9 +66,6 @@ mq_local_ref (quota_local_t *);
 int32_t
 mq_local_unref (xlator_t *, quota_local_t *);
 
-void
-mq_contri_fini (void *data);
-
 inode_contribution_t*
 mq_contri_init (inode_t *inode);
 
-- 
1.8.3.1