]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb: Reduce indentation in get_tunable_values()
authorVolker Lendecke <vl@samba.org>
Thu, 28 Sep 2023 13:55:36 +0000 (15:55 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 10 Oct 2023 13:14:31 +0000 (13:14 +0000)
Use an early return tvals; review with "git sh -b".

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
ctdb/tests/src/ctdb_takeover_tests.c

index 19c897b26ff1a8e4344dc43065e2c1c65785bd18..ad7d7ee9e50048637231632982282ca44631a1e0 100644 (file)
@@ -84,24 +84,27 @@ static uint32_t *get_tunable_values(TALLOC_CTX *tmp_ctx,
        uint32_t *tvals = talloc_zero_array(tmp_ctx, uint32_t, numnodes);
        char *t = getenv(tunable);
 
-       if (t) {
-               if (strcmp(t, "1") == 0) {
-                       for (i=0; i<numnodes; i++) {
-                               tvals[i] = 1;
-                       }
-               } else {
-                       tok = strtok(t, ",");
-                       i = 0;
-                       while (tok != NULL) {
-                               tvals[i] =
-                                       (uint32_t) strtol(tok, NULL, 0);
-                               i++;
-                               tok = strtok(NULL, ",");
-                       }
-                       if (i != numnodes) {
-                               fprintf(stderr, "ERROR: Wrong number of values in %s\n", tunable);
-                               exit(1);
-                       }
+       if (t == NULL) {
+               return tvals;
+       }
+
+       if (strcmp(t, "1") == 0) {
+               for (i = 0; i < numnodes; i++) {
+                       tvals[i] = 1;
+               }
+       } else {
+               tok = strtok(t, ",");
+               i = 0;
+               while (tok != NULL) {
+                       tvals[i] = (uint32_t)strtol(tok, NULL, 0);
+                       i++;
+                       tok = strtok(NULL, ",");
+               }
+               if (i != numnodes) {
+                       fprintf(stderr,
+                               "ERROR: Wrong number of values in %s\n",
+                               tunable);
+                       exit(1);
                }
        }