]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/show-status: use strlen where appropriate 32311/head
authorMike Yuan <me@yhndnzj.com>
Wed, 17 Apr 2024 08:48:29 +0000 (16:48 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 17 Apr 2024 09:04:24 +0000 (17:04 +0800)
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

index 606237ee0eaa45f51f6a0d6a4bd4f12d05b76a13..81b6b23fd7dd253d6f65a7d85905c5718a067814 100644 (file)
@@ -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)