From: Masatake YAMATO Date: Fri, 4 Apr 2025 00:27:10 +0000 (+0900) Subject: treewide: use strtopid_or_err() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f94cf01b8dcc1ed08bad0c00167736e1304f5501;p=thirdparty%2Futil-linux.git treewide: use strtopid_or_err() Addresses: https://github.com/util-linux/util-linux/pull/3486 Suggested-by: Thomas Weißschuh Signed-off-by: Masatake YAMATO --- diff --git a/misc-utils/logger.c b/misc-utils/logger.c index a96b0056f..91a736b8c 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -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; diff --git a/misc-utils/lslocks.c b/misc-utils/lslocks.c index 6cc743185..a0017c4ca 100644 --- a/misc-utils/lslocks.c +++ b/misc-utils/lslocks.c @@ -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; diff --git a/schedutils/chrt.c b/schedutils/chrt.c index 104ee23a0..4f6a027f3 100644 --- a/schedutils/chrt.c +++ b/schedutils/chrt.c @@ -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': diff --git a/schedutils/taskset.c b/schedutils/taskset.c index 8408f86da..46fef5051 100644 --- a/schedutils/taskset.c +++ b/schedutils/taskset.c @@ -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; diff --git a/schedutils/uclampset.c b/schedutils/uclampset.c index 3aa198568..eb3e449ff 100644 --- a/schedutils/uclampset.c +++ b/schedutils/uclampset.c @@ -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; diff --git a/sys-utils/choom.c b/sys-utils/choom.c index 4bf746b61..673b6f7e2 100644 --- a/sys-utils/choom.c +++ b/sys-utils/choom.c @@ -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")); diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index bbf79597d..6b6ad8355 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -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; diff --git a/sys-utils/prlimit.c b/sys-utils/prlimit.c index fbab0082b..d23e0a599 100644 --- a/sys-utils/prlimit.c +++ b/sys-utils/prlimit.c @@ -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,