From ed67739ad507b4371edd2c09c43a45874d50d35b Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 17 Apr 2024 16:48:29 +0800 Subject: [PATCH] core/show-status: use strlen where appropriate We don't use sizeof() outside of array definitions these days. The compiler should be capable of optimizing this out. --- src/core/show-status.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/show-status.c b/src/core/show-status.c index 606237ee0ea..81b6b23fd7d 100644 --- a/src/core/show-status.c +++ b/src/core/show-status.c @@ -38,11 +38,12 @@ int parse_show_status(const char *v, ShowStatus *ret) { int status_vprintf(const char *status, ShowStatusFlags flags, const char *format, va_list ap) { static const char status_indent[] = " "; /* "[" STATUS "] " */ + static bool prev_ephemeral = false; + _cleanup_free_ char *s = NULL; _cleanup_close_ int fd = -EBADF; struct iovec iovec[7] = {}; int n = 0; - static bool prev_ephemeral; assert(format); @@ -70,7 +71,7 @@ int status_vprintf(const char *status, ShowStatusFlags flags, const char *format if (c <= 0) c = 80; - sl = status ? sizeof(status_indent)-1 : 0; + sl = status ? strlen(status_indent) : 0; emax = c - sl - 1; if (emax < 3) -- 2.39.2