]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
quotacheck: drop unnecessary use of global variable
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Jul 2025 19:48:23 +0000 (04:48 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 15 Jul 2025 20:47:38 +0000 (05:47 +0900)
src/quotacheck/quotacheck.c

index 23a5f414c5c4232d9c08bda1a2dda2b89abd37ff..b98819f0efec4db52ac3fdf3f820b19a90ca9e5b 100644 (file)
@@ -7,15 +7,11 @@
 #include "main-func.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
-#include "static-destruct.h"
 #include "string-util.h"
 
-static char *arg_path = NULL;
 static bool arg_skip = false;
 static bool arg_force = false;
 
-STATIC_DESTRUCTOR_REGISTER(arg_path, freep);
-
 static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
 
         if (streq(key, "quotacheck.mode")) {
@@ -68,9 +64,10 @@ static int run(int argc, char *argv[]) {
                 }
         }
 
+        _cleanup_free_ char *path = NULL;
         if (argc == 2) {
-                arg_path = strdup(argv[1]);
-                if (!arg_path)
+                path = strdup(argv[1]);
+                if (!path)
                         return log_oom();
         }
 
@@ -80,8 +77,8 @@ static int run(int argc, char *argv[]) {
         if (r == 0) {
                 const char *cmdline[] = {
                         QUOTACHECK,
-                        arg_path ? "-nug" : "-anug", /* Check all file systems if path isn't specified */
-                        arg_path,
+                        path ? "-nug" : "-anug", /* Check all file systems if path isn't specified */
+                        path,
                         NULL
                 };