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