util: use already computed strlen v2

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1252>
This commit is contained in:
Kacper Piwiński 2025-06-29 17:38:48 +00:00
parent 8ab0e53812
commit 812bcd68f7

View file

@ -150,12 +150,12 @@ stringbuf_append_from_fd(struct stringbuf *b, int fd, size_t maxlen)
static inline int
stringbuf_append_string(struct stringbuf *b, const char *msg)
{
int r = stringbuf_ensure_space(b, strlen(msg) + 1);
size_t slen = strlen(msg);
int r = stringbuf_ensure_space(b, slen + 1);
if (r < 0)
return r;
size_t slen = strlen(msg);
if (!b->data) /* cannot happen, but let's make scan-build happy */
abort();