glusterfs icon indicating copy to clipboard operation
glusterfs copied to clipboard

glusterd: cleanup __server_getspec()

Open dmantipov opened this issue 2 years ago • 4 comments

Simplify __server_getspec() by using gf_asprintf(), add proper error handling.

Signed-off-by: Dmitry Antipov [email protected] Updates: #1000

dmantipov avatar Jun 27 '22 13:06 dmantipov

CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format

index db0dee023..2dfd78124 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -992,15 +992,15 @@ __server_getspec(rpcsvc_request_t *req)
         if (!peer->connected)
             continue;
         if (!peer_hosts) {
-            ret = gf_asprintf(&peer_hosts, "%s:%d ", peer->hostname,
-                              (peer->port ? peer->port :
-                               GLUSTERD_DEFAULT_PORT));
+            ret = gf_asprintf(
+                &peer_hosts, "%s:%d ", peer->hostname,
+                (peer->port ? peer->port : GLUSTERD_DEFAULT_PORT));
             if (ret < 0)
                 break;
         } else {
-            ret = gf_asprintf(&tmp_str, "%s%s:%d ", peer_hosts, peer->hostname,
-                              (peer->port ? peer->port :
-                               GLUSTERD_DEFAULT_PORT));
+            ret = gf_asprintf(
+                &tmp_str, "%s%s:%d ", peer_hosts, peer->hostname,
+                (peer->port ? peer->port : GLUSTERD_DEFAULT_PORT));
             if (ret < 0)
                 break;
             GF_FREE(peer_hosts);

gluster-ant avatar Jun 27 '22 14:06 gluster-ant

/run regression

dmantipov avatar Jun 27 '22 16:06 dmantipov

1 test(s) failed ./tests/basic/glusterd/volfile_server_switch.t

0 test(s) generated core

5 test(s) needed retry ./tests/000-flaky/basic_afr_split-brain-favorite-child-policy.t ./tests/000-flaky/basic_distribute_rebal-all-nodes-migrate.t ./tests/000-flaky/basic_mount-nfs-auth.t ./tests/000-flaky/bugs_nfs_bug-1116503.t ./tests/basic/glusterd/volfile_server_switch.t

3 flaky test(s) marked as success even though they failed ./tests/000-flaky/basic_distribute_rebal-all-nodes-migrate.t ./tests/000-flaky/basic_mount-nfs-auth.t ./tests/000-flaky/bugs_nfs_bug-1116503.t https://build.gluster.org/job/gh_centos7-regression/2591/

gluster-ant avatar Jun 27 '22 17:06 gluster-ant

/run regression

dmantipov avatar Jun 28 '22 10:06 dmantipov