]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Reduce indentation with an early return
authorVolker Lendecke <vl@samba.org>
Wed, 14 Jan 2026 09:11:18 +0000 (10:11 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 20 Jan 2026 11:53:34 +0000 (11:53 +0000)
Review with "git show -w"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/lib/sysquotas.c

index 12573eb554a93cee1de639a875c0a5f04a7b80b9..5f8d06634d6b6586761952b47b58de6d675f5387 100644 (file)
@@ -249,6 +249,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                loadparm_s3_global_substitution();
        const char *get_quota_command = NULL;
        char **lines = NULL;
+       char *line = NULL;
        const char *p = NULL;
        char *p2 = NULL;
        int _id = -1;
@@ -293,115 +294,110 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
        lines = file_lines_ploadv(talloc_tos(), argl, NULL);
        TALLOC_FREE(argl);
 
-       if (lines) {
-               char *line = lines[0];
+       if (lines == NULL) {
+               DBG_ERR("get_quota_command failed!\n");
+               return -1;
+       }
 
-               DBG_NOTICE("Read output from get_quota, \"%s\"\n", line);
+       line = lines[0];
 
-               /* we need to deal with long long unsigned here, if supported */
+       DBG_NOTICE("Read output from get_quota, \"%s\"\n", line);
 
-               dp->qflags = smb_strtoul(line,
-                                        &p2,
-                                        10,
-                                        &error,
-                                        SMB_STR_STANDARD);
-               if (error != 0) {
-                       goto invalid_param;
-               }
+       /* we need to deal with long long unsigned here, if supported */
 
-               p = p2;
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       dp->qflags = smb_strtoul(line, &p2, 10, &error, SMB_STR_STANDARD);
+       if (error != 0) {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->curblocks = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       p = p2;
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->curblocks = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->softlimit = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->softlimit = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->hardlimit = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->hardlimit = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->curinodes = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->curinodes = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->isoftlimit = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->isoftlimit = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->ihardlimit = STR_TO_SMB_BIG_UINT(p, &p);
-               } else {
-                       goto invalid_param;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               while (p && *p && isspace(*p)) {
-                       p++;
-               }
+       if (p && *p) {
+               dp->ihardlimit = STR_TO_SMB_BIG_UINT(p, &p);
+       } else {
+               goto invalid_param;
+       }
 
-               if (p && *p) {
-                       dp->bsize = STR_TO_SMB_BIG_UINT(p, NULL);
-               } else {
-                       dp->bsize = 1024;
-               }
+       while (p && *p && isspace(*p)) {
+               p++;
+       }
 
-               TALLOC_FREE(lines);
-               lines = NULL;
-
-               DBG_INFO("Parsed output of get_quota, ...\n"
-                        "qflags:%" PRIu32 " curblocks:%" PRIu64
-                        " softlimit:%" PRIu64 " hardlimit:%" PRIu64
-                        "\n"
-                        "curinodes:%" PRIu64 " isoftlimit:%" PRIu64
-                        " ihardlimit:%" PRIu64 " bsize:%" PRIu64 "\n",
-                        dp->qflags,
-                        dp->curblocks,
-                        dp->softlimit,
-                        dp->hardlimit,
-                        dp->curinodes,
-                        dp->isoftlimit,
-                        dp->ihardlimit,
-                        dp->bsize);
-               return 0;
+       if (p && *p) {
+               dp->bsize = STR_TO_SMB_BIG_UINT(p, NULL);
+       } else {
+               dp->bsize = 1024;
        }
 
-       DBG_ERR("get_quota_command failed!\n");
-       return -1;
+       TALLOC_FREE(lines);
+       lines = NULL;
+
+       DBG_INFO("Parsed output of get_quota, ...\n"
+                "qflags:%" PRIu32 " curblocks:%" PRIu64 " softlimit:%" PRIu64
+                " hardlimit:%" PRIu64 "\n"
+                "curinodes:%" PRIu64 " isoftlimit:%" PRIu64
+                " ihardlimit:%" PRIu64 " bsize:%" PRIu64 "\n",
+                dp->qflags,
+                dp->curblocks,
+                dp->softlimit,
+                dp->hardlimit,
+                dp->curinodes,
+                dp->isoftlimit,
+                dp->ihardlimit,
+                dp->bsize);
+       return 0;
 
 invalid_param: