]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-util: use pointer returned by startswith()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 14:50:17 +0000 (23:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 17:12:29 +0000 (02:12 +0900)
src/shared/fstab-util.c

index 67e718b6eaa61d129233ee8bf81e472065e820d1..c121d2617947ddcf0244b62fa2ce4f05e20bcb98 100644 (file)
@@ -305,19 +305,25 @@ static char *tag_to_udev_node(const char *tagvalue, const char *by) {
 }
 
 char *fstab_node_to_udev_node(const char *p) {
+        const char *q;
+
         assert(p);
 
-        if (startswith(p, "LABEL="))
-                return tag_to_udev_node(p+6, "label");
+        q = startswith(p, "LABEL=");
+        if (q)
+                return tag_to_udev_node(q, "label");
 
-        if (startswith(p, "UUID="))
-                return tag_to_udev_node(p+5, "uuid");
+        q = startswith(p, "UUID=");
+        if (q)
+                return tag_to_udev_node(q, "uuid");
 
-        if (startswith(p, "PARTUUID="))
-                return tag_to_udev_node(p+9, "partuuid");
+        q = startswith(p, "PARTUUID=");
+        if (q)
+                return tag_to_udev_node(q, "partuuid");
 
-        if (startswith(p, "PARTLABEL="))
-                return tag_to_udev_node(p+10, "partlabel");
+        q = startswith(p, "PARTLABEL=");
+        if (q)
+                return tag_to_udev_node(q, "partlabel");
 
         return strdup(p);
 }