]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Save a few lines with str_list_add_printf()
authorVolker Lendecke <vl@samba.org>
Wed, 12 Jan 2022 11:19:00 +0000 (12:19 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 18 Jan 2022 20:22:38 +0000 (20:22 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/sysquotas.c

index 14c07a26f4e5f5d6ef2628e3e74a9fa884063950..07d28d3a410a6d3b6b02a3e990c61a7a15106553 100644 (file)
@@ -432,66 +432,25 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
                                return -1;
                }
 
-               argl = talloc_zero_array(talloc_tos(), char *, 11);
+               argl = str_list_make_empty(talloc_tos());
+               str_list_add_printf(&argl, "%s", set_quota_command);
+               str_list_add_printf(&argl, "%s", path);
+               str_list_add_printf(&argl, "%d", qtype);
+               str_list_add_printf(&argl, "%d", _id);
+               str_list_add_printf(&argl, "%u", dp->qflags);
+               str_list_add_printf(
+                       &argl, "%llu", (long long unsigned)dp->softlimit);
+               str_list_add_printf(
+                       &argl, "%llu", (long long unsigned)dp->hardlimit);
+               str_list_add_printf(
+                       &argl, "%llu", (long long unsigned)dp->isoftlimit);
+               str_list_add_printf(
+                       &argl, "%llu", (long long unsigned)dp->ihardlimit);
+               str_list_add_printf(
+                       &argl, "%llu", (long long unsigned)dp->bsize);
                if (argl == NULL) {
                        return -1;
                }
-               argl[0] = talloc_strdup(argl, set_quota_command);
-               if (argl[0] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[1] = talloc_strdup(argl, path);
-               if (argl[1] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[2] = talloc_asprintf(argl, "%d", qtype);
-               if (argl[2] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[3] = talloc_asprintf(argl, "%d", _id);
-               if (argl[3] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[4] = talloc_asprintf(argl, "%u", dp->qflags);
-               if (argl[4] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[5] = talloc_asprintf(argl, "%llu",
-                               (long long unsigned)dp->softlimit);
-               if (argl[5] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[6] = talloc_asprintf(argl, "%llu",
-                               (long long unsigned)dp->hardlimit);
-               if (argl[6] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[7] = talloc_asprintf(argl, "%llu",
-                               (long long unsigned)dp->isoftlimit);
-               if (argl[7] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[8] = talloc_asprintf(argl, "%llu",
-                               (long long unsigned)dp->ihardlimit);
-               if (argl[8] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[9] = talloc_asprintf(argl, "%llu",
-                               (long long unsigned)dp->bsize);
-               if (argl[9] == NULL) {
-                       TALLOC_FREE(argl);
-                       return -1;
-               }
-               argl[10] = NULL;
 
                DBG_NOTICE("Running command "
                        "%s %s %d %d "