From: Lennart Poettering Date: Thu, 14 Dec 2017 18:02:29 +0000 (+0100) Subject: tree-wide: make use of new STRLEN() macro everywhere (#7639) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=2205140c2dca028beb4870267b98bd6c76d07385;p=elogind.git tree-wide: make use of new STRLEN() macro everywhere (#7639) Let's employ coccinelle to do this for us. Follow-up for #7625. --- diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 050e04263..3fb2fac31 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -1504,7 +1504,7 @@ static bool valid_slice_name(const char *p, size_t n) { if (!p) return false; - if (n < strlen("x.slice")) + if (n < STRLEN("x.slice")) return false; if (memcmp(p + n - 6, ".slice", 6) == 0) { @@ -1588,7 +1588,7 @@ static const char *skip_session(const char *p) { p += strspn(p, "/"); n = strcspn(p, "/"); - if (n < strlen("session-x.scope")) + if (n < STRLEN("session-x.scope")) return NULL; if (memcmp(p, "session-", 8) == 0 && memcmp(p + n - 6, ".scope", 6) == 0) { @@ -1625,7 +1625,7 @@ static const char *skip_user_manager(const char *p) { p += strspn(p, "/"); n = strcspn(p, "/"); - if (n < strlen("user@x.service")) + if (n < STRLEN("user@x.service")) return NULL; if (memcmp(p, "user@", 5) == 0 && memcmp(p + n - 8, ".service", 8) == 0) { diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 0b3527de7..5a918c1e7 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -1483,7 +1483,7 @@ int link_tmpfile(int fd, const char *path, const char *target) { if (rename_noreplace(AT_FDCWD, path, AT_FDCWD, target) < 0) return -errno; } else { - char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1]; + char proc_fd_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1]; xsprintf(proc_fd_path, "/proc/self/fd/%i", fd); diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index d2cc70d5c..03e1b9a42 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -116,7 +116,7 @@ int name_to_handle_at_loop( } static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id) { - char path[strlen("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; + char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)]; _cleanup_free_ char *fdinfo = NULL; _cleanup_close_ int subfd = -1; char *p; diff --git a/src/basic/process-util.h b/src/basic/process-util.h index be4f2cfe1..5f6954d1c 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -33,7 +33,6 @@ #include "format-util.h" //#include "ioprio.h" #include "macro.h" -//#include "time-util.h" #define procfs_file_alloca(pid, field) \ ({ \ @@ -65,7 +64,6 @@ int get_process_ppid(pid_t pid, pid_t *ppid); int wait_for_terminate(pid_t pid, siginfo_t *status); int wait_for_terminate_and_warn(const char *name, pid_t pid, bool check_exit_code); #if 0 /// UNNEEDED by elogind -int wait_for_terminate_with_timeout(pid_t pid, usec_t timeout); void sigkill_wait(pid_t pid); void sigkill_waitp(pid_t *pid);