]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: port various places to find_line_startswith()
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Mar 2023 17:25:13 +0000 (18:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 24 Mar 2023 17:30:20 +0000 (18:30 +0100)
src/basic/mountpoint-util.c
src/basic/process-util.c
src/import/importd.c
src/shared/logs-show.c

index ad22894a59e9349d26e72b7cbd324b4016e05bd0..751d5a35ce0ff8a13a55d17e91d9c664994f9e73 100644 (file)
@@ -125,14 +125,9 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mn
         if (r < 0)
                 return r;
 
-        p = startswith(fdinfo, "mnt_id:");
-        if (!p) {
-                p = strstr(fdinfo, "\nmnt_id:");
-                if (!p) /* The mnt_id field is a relatively new addition */
-                        return -EOPNOTSUPP;
-
-                p += 8;
-        }
+        p = find_line_startswith(fdinfo, "mnt_id:");
+        if (!p) /* The mnt_id field is a relatively new addition */
+                return -EOPNOTSUPP;
 
         p += strspn(p, WHITESPACE);
         p[strcspn(p, WHITESPACE)] = 0;
index cf2dca1dc481057ea4b1a1f09ce3d954b8f1c93d..c891f74be8fea9eb2c76c5c2c511f28d5f6627a5 100644 (file)
@@ -1453,14 +1453,9 @@ int pidfd_get_pid(int fd, pid_t *ret) {
         if (r < 0)
                 return r;
 
-        p = startswith(fdinfo, "Pid:");
-        if (!p) {
-                p = strstr(fdinfo, "\nPid:");
-                if (!p)
-                        return -ENOTTY; /* not a pidfd? */
-
-                p += 5;
-        }
+        p = find_line_startswith(fdinfo, "Pid:");
+        if (!p)
+                return -ENOTTY; /* not a pidfd? */
 
         p += strspn(p, WHITESPACE);
         p[strcspn(p, WHITESPACE)] = 0;
index ed757019cf989c478af933995b2b09b73d28ee4e..4675aa5a6120ac74f4c3f374158bfc2a902ae952 100644 (file)
@@ -590,14 +590,9 @@ static int manager_on_notify(sd_event_source *s, int fd, uint32_t revents, void
 
         buf[n] = 0;
 
-        p = startswith(buf, "X_IMPORT_PROGRESS=");
-        if (!p) {
-                p = strstr(buf, "\nX_IMPORT_PROGRESS=");
-                if (!p)
-                        return 0;
-
-                p += 19;
-        }
+        p = find_line_startswith(buf, "X_IMPORT_PROGRESS=");
+        if (!p)
+                return 0;
 
         e = strchrnul(p, '\n');
         *e = 0;
index 6ed9a6890f5e73cba0bfc1a2f01f15350147198e..d372e096c494afd3f8d606307909183852e02d31 100644 (file)
@@ -93,14 +93,9 @@ static int url_from_catalog(sd_journal *j, char **ret) {
         if (r < 0)
                 return log_error_errno(r, "Failed to find catalog entry: %m");
 
-        weblink = startswith(t, "Documentation:");
-        if (!weblink) {
-                weblink = strstr(t + 1, "\nDocumentation:");
-                if (!weblink)
-                        goto notfound;
-
-                weblink += 15;
-        }
+        weblink = find_line_startswith(t, "Documentation:");
+        if (!weblink)
+                goto notfound;
 
         /* Skip whitespace to value */
         weblink += strspn(weblink, " \t");