aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2021-01-14 21:30:06 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-21 10:57:46 +0000
commitd2c00d73ec087e2266d8e07daacb0732fc1ca761 (patch)
tree4bdbf8d3c357ac6880de00a06f83402bac48518b /main.c
parentsixel: current geometry: don’t exceed current window dimensions (diff)
Add xsnprintf() and remove some unnecessary strlen(3) calls
Diffstat (limited to 'main.c')
-rw-r--r--main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.c b/main.c
index 094c242a..4423ec7a 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) {