]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: use path friendly functions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 22 Oct 2018 04:46:35 +0000 (13:46 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 09:28:38 +0000 (18:28 +0900)
src/udev/udevadm-util.c

index 6cff5ef84c061d6ebd66aa651d943f7eca12095f..1dbcf979b171cc6b049b7949b0c6e9a216842b9d 100644 (file)
@@ -2,17 +2,23 @@
 
 #include <errno.h>
 
+#include "alloc-util.h"
 #include "device-private.h"
 #include "path-util.h"
-#include "string-util.h"
 #include "udevadm-util.h"
 
 int find_device(const char *id, const char *prefix, sd_device **ret) {
+        _cleanup_free_ char *buf = NULL;
+
         assert(id);
         assert(ret);
 
-        if (prefix && !startswith(id, prefix))
-                id = strjoina(prefix, id);
+        if (prefix && !path_startswith(id, prefix)) {
+                buf = path_join(NULL, prefix, id);
+                if (!buf)
+                        return -ENOMEM;
+                id = buf;
+        }
 
         if (path_startswith(id, "/sys/"))
                 return sd_device_new_from_syspath(ret, id);