fstab-util: use pointer returned by startswith()

This commit is contained in:
Yu Watanabe
2023-08-01 02:12:29 +09:00
parent e4f2f14f1e
commit 2668d040c1
+14 -8
View 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);
}