21ab4e
From e4561754a2ca05cab143d2fb3f3102fad9ed8b94 Mon Sep 17 00:00:00 2001
21ab4e
From: Niels de Vos <ndevos@redhat.com>
21ab4e
Date: Tue, 16 May 2017 19:46:04 +0200
21ab4e
Subject: [PATCH 446/473] refcount: typecast function for calling on free
21ab4e
21ab4e
All of the functions called to free the refcounted structure are doing a
21ab4e
typecast from (void*) to their own type taht is being free'd. This
21ab4e
really is not needed and the refcount interface is made a little simpler
21ab4e
without the requirement of typecasting.
21ab4e
21ab4e
With this small improvement in the API, all callers are updated too.
21ab4e
21ab4e
Cherry picked from commit f2ca301bd741e3e3f076cd3f72fcd377bcef2a1a:
21ab4e
> Change-Id: I32473b6d1799f62861d4b2d78ea30c09e6c80ab1
21ab4e
> BUG: 1416889
21ab4e
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/16471
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
21ab4e
21ab4e
There has been a slight omission in the backport of change
21ab4e
I19d225b39aaa272d9005ba7adc3104c3764f1572. This missing backport results
21ab4e
in compiler warnings like:
21ab4e
21ab4e
    ctx.c: In function 'glusterfs_ctx_tw_get':
21ab4e
    ctx.c:72:25: warning: passing argument 2 of '_gf_ref_init' from incompatible pointer type [enabled by default]
21ab4e
                             GF_REF_INIT (ctx_tw, glusterfs_ctx_tw_destroy);
21ab4e
21ab4e
Change-Id: I32473b6d1799f62861d4b2d78ea30c09e6c80ab1
21ab4e
BUG: 1450336
21ab4e
Signed-off-by: Niels de Vos <ndevos@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106357
21ab4e
Reviewed-by: Poornima Gurusiddaiah <pgurusid@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 api/src/glfs.c                                    | 10 +++-------
21ab4e
 libglusterfs/src/refcount.h                       |  2 +-
21ab4e
 rpc/rpc-transport/socket/src/socket.c             |  6 ++----
21ab4e
 xlators/cluster/dht/src/dht-helper.c              |  9 ++-------
21ab4e
 xlators/features/marker/src/marker-quota-helper.c |  6 ++----
21ab4e
 xlators/features/marker/src/marker-quota-helper.h |  3 ---
21ab4e
 6 files changed, 10 insertions(+), 26 deletions(-)
21ab4e
21ab4e
diff --git a/api/src/glfs.c b/api/src/glfs.c
21ab4e
index 62441c9..253b98d 100644
21ab4e
--- a/api/src/glfs.c
21ab4e
+++ b/api/src/glfs.c
21ab4e
@@ -540,16 +540,12 @@ pub_glfs_from_glfd (struct glfs_fd *glfd)
21ab4e
 
21ab4e
 GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_from_glfd, 3.4.0);
21ab4e
 
21ab4e
-void
21ab4e
-glfs_fd_destroy (void *data)
21ab4e
+static void
21ab4e
+glfs_fd_destroy (struct glfs_fd *glfd)
21ab4e
 {
21ab4e
-        struct glfs_fd  *glfd = NULL;
21ab4e
-
21ab4e
-        if (!data)
21ab4e
+        if (!glfd)
21ab4e
                 return;
21ab4e
 
21ab4e
-        glfd = (struct glfs_fd *)data;
21ab4e
-
21ab4e
         glfs_lock (glfd->fs, _gf_true);
21ab4e
         {
21ab4e
                 list_del_init (&glfd->openfds);
21ab4e
diff --git a/libglusterfs/src/refcount.h b/libglusterfs/src/refcount.h
21ab4e
index db9432a..583b75c 100644
21ab4e
--- a/libglusterfs/src/refcount.h
21ab4e
+++ b/libglusterfs/src/refcount.h
21ab4e
@@ -84,7 +84,7 @@ _gf_ref_init (gf_ref_t *ref, gf_ref_release_t release, void *data);
21ab4e
  *
21ab4e
  * Sets the refcount to 1.
21ab4e
  */
21ab4e
-#define GF_REF_INIT(p, d)   _gf_ref_init (&(p)->_ref, d, p)
21ab4e
+#define GF_REF_INIT(p, d)   _gf_ref_init (&(p)->_ref, (gf_ref_release_t) d, p)
21ab4e
 
21ab4e
 /* GF_REF_GET -- increase the refcount of a GF_REF_DECL structure
21ab4e
  *
21ab4e
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
21ab4e
index f64e2f0..07cf7a6 100644
21ab4e
--- a/rpc/rpc-transport/socket/src/socket.c
21ab4e
+++ b/rpc/rpc-transport/socket/src/socket.c
21ab4e
@@ -3929,11 +3929,9 @@ init_openssl_mt (void)
21ab4e
         SSL_load_error_strings();
21ab4e
 }
21ab4e
 
21ab4e
-void
21ab4e
-socket_poller_mayday (void *data)
21ab4e
+static void
21ab4e
+socket_poller_mayday (socket_private_t *priv)
21ab4e
 {
21ab4e
-        socket_private_t *priv = (socket_private_t *)data;
21ab4e
-
21ab4e
         if (priv == NULL)
21ab4e
                 return;
21ab4e
 
21ab4e
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
21ab4e
index 255c082..c22f700 100644
21ab4e
--- a/xlators/cluster/dht/src/dht-helper.c
21ab4e
+++ b/xlators/cluster/dht/src/dht-helper.c
21ab4e
@@ -15,15 +15,10 @@
21ab4e
 #include "dht-helper.h"
21ab4e
 
21ab4e
 
21ab4e
-void
21ab4e
-dht_free_fd_ctx (void *data)
21ab4e
+static void
21ab4e
+dht_free_fd_ctx (dht_fd_ctx_t *fd_ctx)
21ab4e
 {
21ab4e
-        dht_fd_ctx_t *fd_ctx = NULL;
21ab4e
-
21ab4e
-        fd_ctx = (dht_fd_ctx_t *)data;
21ab4e
         GF_FREE (fd_ctx);
21ab4e
-
21ab4e
-        return;
21ab4e
 }
21ab4e
 
21ab4e
 
21ab4e
diff --git a/xlators/features/marker/src/marker-quota-helper.c b/xlators/features/marker/src/marker-quota-helper.c
21ab4e
index 1fed9df..e3e218f 100644
21ab4e
--- a/xlators/features/marker/src/marker-quota-helper.c
21ab4e
+++ b/xlators/features/marker/src/marker-quota-helper.c
21ab4e
@@ -146,11 +146,9 @@ out:
21ab4e
         return ctx;
21ab4e
 }
21ab4e
 
21ab4e
-void
21ab4e
-mq_contri_fini (void *data)
21ab4e
+static void
21ab4e
+mq_contri_fini (inode_contribution_t *contri)
21ab4e
 {
21ab4e
-        inode_contribution_t *contri = data;
21ab4e
-
21ab4e
         LOCK_DESTROY (&contri->lock);
21ab4e
         GF_FREE (contri);
21ab4e
 }
21ab4e
diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h
21ab4e
index bf417aa..444ba7c 100644
21ab4e
--- a/xlators/features/marker/src/marker-quota-helper.h
21ab4e
+++ b/xlators/features/marker/src/marker-quota-helper.h
21ab4e
@@ -66,9 +66,6 @@ mq_local_ref (quota_local_t *);
21ab4e
 int32_t
21ab4e
 mq_local_unref (xlator_t *, quota_local_t *);
21ab4e
 
21ab4e
-void
21ab4e
-mq_contri_fini (void *data);
21ab4e
-
21ab4e
 inode_contribution_t*
21ab4e
 mq_contri_init (inode_t *inode);
21ab4e
 
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e