]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
treewide: use strtopid_or_err()
authorMasatake YAMATO <yamato@redhat.com>
Fri, 4 Apr 2025 00:27:10 +0000 (09:27 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Fri, 4 Apr 2025 06:55:36 +0000 (15:55 +0900)
Addresses: https://github.com/util-linux/util-linux/pull/3486
Suggested-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/logger.c
misc-utils/lslocks.c
schedutils/chrt.c
schedutils/taskset.c
schedutils/uclampset.c
sys-utils/choom.c
sys-utils/lsns.c
sys-utils/prlimit.c

index a96b0056fb4db6b2c95311a939ca7cefc6b674a9..91a736b8cb0a103466c18cbf14b669316b9b47ee 100644 (file)
@@ -1206,7 +1206,7 @@ int main(int argc, char **argv)
 
                                if (*p == '=')
                                        p++;
-                               ctl.pid = strtoul_or_err(optarg, _("failed to parse id"));
+                               ctl.pid = strtopid_or_err(optarg, _("failed to parse id"));
                        } else
                                ctl.pid = logger_getpid();
                        break;
index 6cc743185cad6205450491b5f832f9bbf55bb313..a0017c4ca5afa6cd3c8a7c216dba8312d02c17ca 100644 (file)
@@ -382,6 +382,7 @@ static struct lock *get_lock(char *buf, struct override_info *oinfo, void *fallb
                                l->pid = oinfo->pid;
                                l->cmdname = xstrdup(oinfo->cmdname);
                        } else {
+                               /* strtopid_or_err() is not suitable here; tok can be -1.*/
                                l->pid = strtos32_or_err(tok, _("failed to parse pid"));
                                if (l->pid > 0) {
                                        l->cmdname = pid_get_cmdname(l->pid);
@@ -902,7 +903,7 @@ int main(int argc, char *argv[])
                        json = 1;
                        break;
                case 'p':
-                       target_pid = strtos32_or_err(optarg, _("invalid PID argument"));
+                       target_pid = strtopid_or_err(optarg, _("invalid PID argument"));
                        break;
                case 'o':
                        outarg = optarg;
index 104ee23a05e73817a831ad79089bf3d68b904e28..4f6a027f3b8c0c741c28119c6a86ed8ee9d8443f 100644 (file)
@@ -454,6 +454,7 @@ int main(int argc, char **argv)
                        break;
                case 'p':
                        errno = 0;
+                       /* strtopid_or_err() is not suitable here; 0 can be passed.*/
                        ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));
                        break;
                case 'r':
index 8408f86dabcb4a49ff21dc6164b07a42ee147d25..46fef5051c70228d2de544453e63d0712505e869 100644 (file)
@@ -187,8 +187,8 @@ int main(int argc, char **argv)
                        all_tasks = 1;
                        break;
                case 'p':
-                       pid = strtos32_or_err(argv[argc - 1],
-                                           _("invalid PID argument"));
+                       pid = strtopid_or_err(argv[argc - 1],
+                                             _("invalid PID argument"));
                        break;
                case 'c':
                        ts.use_list = 1;
index 3aa1985683fcf0bcd579a789f8686a5aa7a931d6..eb3e449ff230101045f251d9c13939a4f63404fa 100644 (file)
@@ -247,7 +247,7 @@ int main(int argc, char **argv)
                        break;
                case 'p':
                        errno = 0;
-                       ctl->pid = strtos32_or_err(optarg, _("invalid PID argument"));
+                       ctl->pid = strtopid_or_err(optarg, _("invalid PID argument"));
                        break;
                case 's':
                        ctl->system = 1;
index 4bf746b61e0a1edced2be116a732cfc7719f896a..673b6f7e2db1620215674247e5d57771c99a79b2 100644 (file)
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
        while ((c = getopt_long(argc, argv, "hn:p:V", longopts, NULL)) != -1) {
                switch (c) {
                case 'p':
-                       pid = strtos32_or_err(optarg, _("invalid PID argument"));
+                       pid = strtopid_or_err(optarg, _("invalid PID argument"));
                        break;
                case 'n':
                        adj = strtos32_or_err(optarg, _("invalid adjust argument"));
index bbf79597deefa1fdbf4bc8444f6154447aea3aa3..6b6ad8355c70acccfdc84c3162e624ab32fa40a2 100644 (file)
@@ -1689,7 +1689,7 @@ int main(int argc, char *argv[])
                        ls.persist = 1;
                        break;
                case 'p':
-                       ls.fltr_pid = strtos32_or_err(optarg, _("invalid PID argument"));
+                       ls.fltr_pid = strtopid_or_err(optarg, _("invalid PID argument"));
                        break;
                case 'n':
                        ls.no_headings = 1;
index fbab0082bb21b590b7d8fa88b6d413db9b0b8c39..d23e0a599148aef68f2c095b657f862256e3ab89 100644 (file)
@@ -596,7 +596,7 @@ int main(int argc, char **argv)
                case 'p':
                        if (pid)
                                errx(EXIT_FAILURE, _("option --pid may be specified only once"));
-                       pid = strtos32_or_err(optarg, _("invalid PID argument"));
+                       pid = strtopid_or_err(optarg, _("invalid PID argument"));
                        break;
                case 'o':
                        ncolumns = string_to_idarray(optarg,