17b94a
From 469cb9e16d46f075caf609ddcb12a7c02d73ce8b Mon Sep 17 00:00:00 2001
17b94a
From: Mohammed Rafi KC <rkavunga@redhat.com>
17b94a
Date: Thu, 11 Jul 2019 12:50:24 +0530
17b94a
Subject: [PATCH 248/255] Revert "shd/mux: Fix coverity issues introduced by
17b94a
 shd mux patch"
17b94a
17b94a
This reverts commit 0021a4bbc9af2bfe28d4a79f76c3cd33f23dd118.
17b94a
17b94a
BUG: 1471742
17b94a
Change-Id: I0749328412ed3cc7ae5d64baea7a90b63b489a08
17b94a
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/175957
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 libglusterfs/src/graph.c                        | 21 ++++++++-------------
17b94a
 xlators/mgmt/glusterd/src/glusterd-shd-svc.c    |  6 ------
17b94a
 xlators/mgmt/glusterd/src/glusterd-svc-helper.c | 24 +++++++-----------------
17b94a
 3 files changed, 15 insertions(+), 36 deletions(-)
17b94a
17b94a
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
17b94a
index 4c8b02d..a492dd8 100644
17b94a
--- a/libglusterfs/src/graph.c
17b94a
+++ b/libglusterfs/src/graph.c
17b94a
@@ -1470,9 +1470,7 @@ glusterfs_process_svc_detach(glusterfs_ctx_t *ctx, gf_volfile_t *volfile_obj)
17b94a
         goto out;
17b94a
     parent_graph = ctx->active;
17b94a
     graph = volfile_obj->graph;
17b94a
-    if (!graph)
17b94a
-        goto out;
17b94a
-    if (graph->first)
17b94a
+    if (graph && graph->first)
17b94a
         xl = graph->first;
17b94a
 
17b94a
     last_xl = graph->last_xl;
17b94a
@@ -1593,10 +1591,12 @@ glusterfs_process_svc_attach_volfp(glusterfs_ctx_t *ctx, FILE *fp,
17b94a
     parent_graph->leaf_count += graph->leaf_count;
17b94a
     parent_graph->id++;
17b94a
 
17b94a
-    volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
17b94a
     if (!volfile_obj) {
17b94a
-        ret = -1;
17b94a
-        goto out;
17b94a
+        volfile_obj = GF_CALLOC(1, sizeof(gf_volfile_t), gf_common_volfile_t);
17b94a
+        if (!volfile_obj) {
17b94a
+            ret = -1;
17b94a
+            goto out;
17b94a
+        }
17b94a
     }
17b94a
 
17b94a
     graph->used = 1;
17b94a
@@ -1641,7 +1641,6 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
17b94a
 {
17b94a
     glusterfs_graph_t *oldvolfile_graph = NULL;
17b94a
     glusterfs_graph_t *newvolfile_graph = NULL;
17b94a
-    char vol_id[NAME_MAX + 1];
17b94a
 
17b94a
     int ret = -1;
17b94a
 
17b94a
@@ -1673,9 +1672,6 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
17b94a
     glusterfs_graph_prepare(newvolfile_graph, ctx, newvolfile_graph->first);
17b94a
 
17b94a
     if (!is_graph_topology_equal(oldvolfile_graph, newvolfile_graph)) {
17b94a
-        ret = snprintf(vol_id, sizeof(vol_id), "%s", volfile_obj->vol_id);
17b94a
-        if (ret < 0)
17b94a
-            goto out;
17b94a
         ret = glusterfs_process_svc_detach(ctx, volfile_obj);
17b94a
         if (ret) {
17b94a
             gf_msg("glusterfsd-mgmt", GF_LOG_ERROR, EINVAL,
17b94a
@@ -1684,9 +1680,8 @@ glusterfs_mux_volfile_reconfigure(FILE *newvolfile_fp, glusterfs_ctx_t *ctx,
17b94a
                    "old graph. Aborting the reconfiguration operation");
17b94a
             goto out;
17b94a
         }
17b94a
-        volfile_obj = NULL;
17b94a
-        ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp, vol_id,
17b94a
-                                                 checksum);
17b94a
+        ret = glusterfs_process_svc_attach_volfp(ctx, newvolfile_fp,
17b94a
+                                                 volfile_obj->vol_id, checksum);
17b94a
         goto out;
17b94a
     }
17b94a
 
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
17b94a
index 19eca9f..4789843 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
17b94a
@@ -101,8 +101,6 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
17b94a
         svc->conn.rpc = rpc_clnt_ref(mux_svc->rpc);
17b94a
         ret = snprintf(svc->conn.sockpath, sizeof(svc->conn.sockpath), "%s",
17b94a
                        mux_conn->sockpath);
17b94a
-        if (ret < 0)
17b94a
-            goto out;
17b94a
     } else {
17b94a
         ret = mkdir_p(logdir, 0755, _gf_true);
17b94a
         if ((ret == -1) && (EEXIST != errno)) {
17b94a
@@ -675,10 +673,6 @@ glusterd_shdsvc_stop(glusterd_svc_t *svc, int sig)
17b94a
         glusterd_volinfo_ref(volinfo);
17b94a
         svc_proc->data = volinfo;
17b94a
         ret = glusterd_svc_stop(svc, sig);
17b94a
-        if (ret) {
17b94a
-            glusterd_volinfo_unref(volinfo);
17b94a
-            goto out;
17b94a
-        }
17b94a
     }
17b94a
     if (!empty && pid != -1) {
17b94a
         ret = glusterd_detach_svc(svc, volinfo, sig);
17b94a
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
17b94a
index 02945b1..e42703c 100644
17b94a
--- a/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
17b94a
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-helper.c
17b94a
@@ -411,14 +411,9 @@ __gf_find_compatible_svc(gd_node_type daemon)
17b94a
     conf = THIS->private;
17b94a
     GF_VALIDATE_OR_GOTO("glusterd", conf, out);
17b94a
 
17b94a
-    switch (daemon) {
17b94a
-        case GD_NODE_SHD: {
17b94a
-            svc_procs = &conf->shd_procs;
17b94a
-            if (!svc_procs)
17b94a
-                goto out;
17b94a
-        } break;
17b94a
-        default:
17b94a
-            /* Add support for other client daemons here */
17b94a
+    if (daemon == GD_NODE_SHD) {
17b94a
+        svc_procs = &conf->shd_procs;
17b94a
+        if (!svc_procs)
17b94a
             goto out;
17b94a
     }
17b94a
 
17b94a
@@ -545,16 +540,11 @@ __gf_find_compatible_svc_from_pid(gd_node_type daemon, pid_t pid)
17b94a
     if (!conf)
17b94a
         return NULL;
17b94a
 
17b94a
-    switch (daemon) {
17b94a
-        case GD_NODE_SHD: {
17b94a
-            svc_procs = &conf->shd_procs;
17b94a
-            if (!svc_procs)
17b94a
-                return NULL;
17b94a
-        } break;
17b94a
-        default:
17b94a
-            /* Add support for other client daemons here */
17b94a
+    if (daemon == GD_NODE_SHD) {
17b94a
+        svc_procs = &conf->shd_procs;
17b94a
+        if (!svc_proc)
17b94a
             return NULL;
17b94a
-    }
17b94a
+    } /* Can be moved to switch when mux is implemented for other daemon; */
17b94a
 
17b94a
     cds_list_for_each_entry(svc_proc, svc_procs, svc_proc_list)
17b94a
     {
17b94a
-- 
17b94a
1.8.3.1
17b94a