aboutsummaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-08-09 19:03:39 +0200
committerLennart Poettering <lennart@poettering.net>2017-08-09 19:03:39 +0200
commit27458ed62945be0f022ff69348a913793337108d (patch)
treea57113e7a1e7eace6b5d539679993706a4d4700c /src/udev
parentutil-lib: add a new skip_dev_prefix() helper (diff)
downloadsystemd-27458ed62945be0f022ff69348a913793337108d.tar.gz
systemd-27458ed62945be0f022ff69348a913793337108d.tar.bz2
systemd-27458ed62945be0f022ff69348a913793337108d.zip
tree-wide: use path_startswith() rather than startswith() where ever that's appropriate
When checking path prefixes we really should use the right APIs, just in case people add multiple slashes to their paths...
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udevadm-test-builtin.c3
-rw-r--r--src/udev/udevadm-util.c5
2 files changed, 5 insertions, 3 deletions
diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c
index 0b180d03e..b5662be5c 100644
--- a/src/udev/udevadm-test-builtin.c
+++ b/src/udev/udevadm-test-builtin.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include "path-util.h"
#include "string-util.h"
#include "udev.h"
@@ -80,7 +81,7 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[]) {
}
/* add /sys if needed */
- if (!startswith(syspath, "/sys"))
+ if (!path_startswith(syspath, "/sys"))
strscpyl(filename, sizeof(filename), "/sys", syspath, NULL);
else
strscpy(filename, sizeof(filename), syspath);
diff --git a/src/udev/udevadm-util.c b/src/udev/udevadm-util.c
index 3539c1d6a..beda7c36b 100644
--- a/src/udev/udevadm-util.c
+++ b/src/udev/udevadm-util.c
@@ -15,6 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "path-util.h"
#include "string-util.h"
#include "udevadm-util.h"
@@ -28,7 +29,7 @@ struct udev_device *find_device(struct udev *udev,
if (prefix && !startswith(id, prefix))
id = strjoina(prefix, id);
- if (startswith(id, "/dev/")) {
+ if (path_startswith(id, "/dev/")) {
struct stat statbuf;
char type;
@@ -43,7 +44,7 @@ struct udev_device *find_device(struct udev *udev,
return NULL;
return udev_device_new_from_devnum(udev, type, statbuf.st_rdev);
- } else if (startswith(id, "/sys/"))
+ } else if (path_startswith(id, "/sys/"))
return udev_device_new_from_syspath(udev, id);
else
return NULL;