]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-util: FOREACH_LINE() excorcism
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:08:30 +0000 (16:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:23:45 +0000 (16:23 +0200)
src/basic/mount-util.c

index 38edef9823c0cc6a866ab754bf207b777265d7f3..358c8a91433e07ce2996a76fa7242543025f3ae3 100644 (file)
@@ -13,6 +13,7 @@
 #include <libmount.h>
 
 #include "alloc-util.h"
+#include "def.h"
 #include "escape.h"
 #include "extract-word.h"
 #include "fd-util.h"
@@ -954,8 +955,8 @@ int mount_option_mangle(
 
 int dev_is_devtmpfs(void) {
         _cleanup_fclose_ FILE *proc_self_mountinfo = NULL;
-        char line[LINE_MAX], *e;
         int mount_id, r;
+        char *e;
 
         r = path_get_mnt_id("/dev", &mount_id);
         if (r < 0)
@@ -967,9 +968,16 @@ int dev_is_devtmpfs(void) {
 
         (void) __fsetlocking(proc_self_mountinfo, FSETLOCKING_BYCALLER);
 
-        FOREACH_LINE(line, proc_self_mountinfo, return -errno) {
+        for (;;) {
+                _cleanup_free_ char *line = NULL;
                 int mid;
 
+                r = read_line(proc_self_mountinfo, LONG_LINE_MAX, &line);
+                if (r < 0)
+                        return r;
+                if (r == 0)
+                        break;
+
                 if (sscanf(line, "%i", &mid) != 1)
                         continue;