From c14e0f62396aeba33c3f176ab92dfb362c7199ea Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Fri, 20 Nov 2020 22:05:46 +0000 Subject: [PATCH] uuidd: use pid_t type when referring to process id Earlier use of a variable that holds switch enabling boolean to hold process id was a little bit strange, and not exactly correct. An int should be good enough to hold any pid, but it is better to be precise and use the type that is meant for the job. Signed-off-by: Sami Kerola --- misc-utils/uuidd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c index ef95946e23..8328bd57e7 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -586,7 +586,7 @@ int main(int argc, char **argv) uuidd_cxt.debug = 1; break; case 'k': - do_kill++; + do_kill = 1; break; case 'n': num = strtou32_or_err(optarg, @@ -694,17 +694,19 @@ int main(int argc, char **argv) if (do_kill) { ret = call_daemon(socket_path, UUIDD_OP_GETPID, buf, sizeof(buf), 0, NULL); - if ((ret > 0) && ((do_kill = atoi((char *) buf)) > 0)) { - ret = kill(do_kill, SIGTERM); + if (0 < ret) { + pid_t pid; + + pid = (pid_t)strtou32_or_err(buf, _("failed to parse pid")); + ret = kill(pid, SIGTERM); if (ret < 0) { if (!uuidd_cxt.quiet) warn(_("couldn't kill uuidd running " - "at pid %d"), do_kill); + "at pid %d"), pid); return EXIT_FAILURE; } if (!uuidd_cxt.quiet) - printf(_("Killed uuidd running at pid %d.\n"), - do_kill); + printf(_("Killed uuidd running at pid %d.\n"), pid); } return EXIT_SUCCESS; } -- 2.47.3