diff options
| author | Craig Barnes <craigbarnes@protonmail.com> | 2024-09-11 19:13:30 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-09-13 07:01:15 +0000 |
| commit | d4a1283797b5a964d92e64c698d65f701a90e1cc (patch) | |
| tree | 936de5689747d1fac28893dd60b0bca2852508ae /notify.c | |
| parent | readme: typo: foot-ctlseq -> foot-ctlseqs (diff) | |
xsnprintf: various improvements related to xvsnprintf() and xsnprintf()
Summary of changes:
* Make xvsnprintf() static
* restrict-qualify pointer arguments (as done by the libc equivalents)
* Make comments and spec references more thorough
* Remove pointless `n <= INT_MAX` assertion (see comment)
* Use FATAL_ERROR() instead of xassert() (since the assertion is inside
a shared util function but the caller is responsible for ensuring the
condition holds true)
* Change some callers to use size_t instead of int for the return value
(negative returns are impossible and all subsequent uses are size_t)
The updated comments and code were taken (and adapted) from:
https://gitlab.com/craigbarnes/dte/-/blob/49260bb154bca0434462a41c061e512540ec2e49/src/util/xsnprintf.c#L6-50
This work was entirely authored by me and I hereby license this
contribution under the MIT license (stated explicitly, so that
there's no ambiguity w.r.t. the original license).
Diffstat (limited to 'notify.c')
| -rw-r--r-- | notify.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -268,7 +268,7 @@ notif_done(struct reaper *reaper, pid_t pid, int status, void *data) } char reply[7 + strlen(id) + 1 + strlen(button_nr) + 2 + 1]; - int n = xsnprintf( + size_t n = xsnprintf( reply, sizeof(reply), "\033]99;i=%s;%s\033\\", id, button_nr); term_to_slave(term, reply, n); } @@ -278,7 +278,7 @@ notif_done(struct reaper *reaper, pid_t pid, int status, void *data) const char *id = notif->id != NULL ? notif->id : "0"; char reply[7 + strlen(id) + 1 + 7 + 1 + 2 + 1]; - int n = xsnprintf( + size_t n = xsnprintf( reply, sizeof(reply), "\033]99;i=%s:p=close;\033\\", id); term_to_slave(term, reply, n); } |
