chiark / gitweb /
tree-wide: make use of new STRLEN() macro everywhere (#7639)
authorLennart Poettering <lennart@poettering.net>
Thu, 14 Dec 2017 18:02:29 +0000 (19:02 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:35 +0000 (07:49 +0200)
Let's employ coccinelle to do this for us.

Follow-up for #7625.

src/basic/cgroup-util.c
src/basic/fileio.c
src/basic/mount-util.c
src/basic/process-util.h

index 050e042633020a64a6e9abdd56dc0e3fdcf33b4d..3fb2fac318285f717f7ab657f9b8a2000c7538da 100644 (file)
@@ -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) {
index 0b3527de73188a7b697f5caa5b193b6583ef84a5..5a918c1e7d6a0b340b3d4de5ae32796f1c75994c 100644 (file)
@@ -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);
 
index d2cc70d5c37b78ca5f22845e7ab587ca3e6ec1d6..03e1b9a427307d759454ed692272fde09285c269 100644 (file)
@@ -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;
index be4f2cfe1636ccbecedc1c48d1e12235a25d6945..5f6954d1c97a009d20df2e9cccdcf54580b7fd92 100644 (file)
@@ -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);