mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
Add xsnprintf() and remove some unnecessary strlen(3) calls
This commit is contained in:
parent
b25b8a78a9
commit
3f4cfa338b
8 changed files with 86 additions and 36 deletions
5
main.c
5
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue