chiark / gitweb /
udev: use startswith() and streq()
[elogind.git] / src / libudev / libudev-device-private.c
index 91fd06c..a4dfa9b 100644 (file)
@@ -31,7 +31,7 @@ static void udev_device_tag(struct udev_device *dev, const char *tag, bool add)
         id = udev_device_get_id_filename(dev);
         if (id == NULL)
                 return;
-        util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/tags/", tag, "/", id, NULL);
+        util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/tags/", tag, "/", id, NULL);
 
         if (add) {
                 int fd;
@@ -60,7 +60,7 @@ int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old,
                         udev_list_entry_foreach(list_entry_current, udev_device_get_tags_list_entry(dev)) {
                                 const char *tag = udev_list_entry_get_name(list_entry_current);
 
-                                if (strcmp(tag, tag_old) == 0) {
+                                if (streq(tag, tag_old)) {
                                         found = true;
                                         break;
                                 }
@@ -108,7 +108,7 @@ int udev_device_update_db(struct udev_device *udev_device)
                 return -1;
 
         has_info = device_has_info(udev_device);
-        util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/data/", id, NULL);
+        util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/data/", id, NULL);
 
         /* do not store anything for otherwise empty devices */
         if (!has_info &&
@@ -138,10 +138,8 @@ int udev_device_update_db(struct udev_device *udev_device)
                 struct udev_list_entry *list_entry;
 
                 if (major(udev_device_get_devnum(udev_device)) > 0) {
-                        size_t devlen = strlen(udev_get_dev_path(udev))+1;
-
                         udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device))
-                                fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]);
+                                fprintf(f, "S:%s\n", udev_list_entry_get_name(list_entry) + strlen(TEST_PREFIX "/dev/"));
                         if (udev_device_get_devlink_priority(udev_device) != 0)
                                 fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device));
                         if (udev_device_get_watch_handle(udev_device) >= 0)
@@ -173,13 +171,12 @@ int udev_device_update_db(struct udev_device *udev_device)
 int udev_device_delete_db(struct udev_device *udev_device)
 {
         const char *id;
-        struct udev *udev = udev_device_get_udev(udev_device);
         char filename[UTIL_PATH_SIZE];
 
         id = udev_device_get_id_filename(udev_device);
         if (id == NULL)
                 return -1;
-        util_strscpyl(filename, sizeof(filename), udev_get_run_path(udev), "/data/", id, NULL);
+        util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/run/udev/data/", id, NULL);
         unlink(filename);
         return 0;
 }