1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-09 12:58:26 +03:00

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.
This commit is contained in:
Mike Yuan 2024-04-17 16:48:29 +08:00
parent c498b2f7ee
commit ed67739ad5
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View 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)