From d4a1283797b5a964d92e64c698d65f701a90e1cc Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Wed, 11 Sep 2024 20:13:30 +0100 Subject: 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). --- osc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'osc.c') diff --git a/osc.c b/osc.c index 63b66dd7..0db11811 100644 --- a/osc.c +++ b/osc.c @@ -739,7 +739,7 @@ kitty_notification(struct terminal *term, char *string) const char *terminator = term->vt.osc.bel ? "\a" : "\033\\"; char reply[128]; - int n = xsnprintf( + size_t n = xsnprintf( reply, sizeof(reply), "\033]99;i=%s:p=?;p=%s:a=%s:o=%s:u=%s:c=1:w=1:s=system,silent,error,warn,warning,info,question%s", reply_id, p_caps, a_caps, when_caps, u_caps, terminator); -- cgit v1.3