From 3f4cfa338b5035b3789ea414eab9f139a18d140b Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Thu, 14 Jan 2021 21:30:06 +0000 Subject: Add xsnprintf() and remove some unnecessary strlen(3) calls --- main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 592e5dfb..ea2d4a27 100644 --- a/main.c +++ b/main.c @@ -31,6 +31,7 @@ #include "util.h" #include "version.h" #include "xmalloc.h" +#include "xsnprintf.h" static volatile sig_atomic_t aborted = 0; @@ -127,9 +128,9 @@ print_pid(const char *pid_file, bool *unlink_at_exit) if (pid_fd >= 0) { char pid[32]; - snprintf(pid, sizeof(pid), "%u\n", getpid()); + size_t n = xsnprintf(pid, sizeof(pid), "%u\n", getpid()); - ssize_t bytes = write(pid_fd, pid, strlen(pid)); + ssize_t bytes = write(pid_fd, pid, n); close(pid_fd); if (bytes < 0) { -- cgit v1.3