From 8e5a620b17c08b0b6277236203ee559b7dadd1d4 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 3 Aug 2010 12:13:53 +0200 Subject: call util_delete_path() only when we actually deleted stuff --- libudev/libudev-util-private.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'libudev') diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index 2f9f4a74c3..6b68b6a366 100644 --- a/libudev/libudev-util-private.c +++ b/libudev/libudev-util-private.c @@ -74,7 +74,7 @@ int util_delete_path(struct udev *udev, const char *path) { char p[UTIL_PATH_SIZE]; char *pos; - int retval; + int err = 0; if (path[0] == '/') while(path[1] == '/') @@ -92,19 +92,14 @@ int util_delete_path(struct udev *udev, const char *path) if ((pos == p) || (pos == NULL)) break; - /* remove if empty */ - retval = rmdir(p); - if (errno == ENOENT) - retval = 0; - if (retval) { - if (errno == ENOTEMPTY) - return 0; - err(udev, "rmdir(%s) failed: %m\n", p); + err = rmdir(p); + if (err < 0) { + if (errno == ENOENT) + err = 0; break; } - dbg(udev, "removed '%s'\n", p); } - return 0; + return err; } /* Reset permissions on the device node, before unlinking it to make sure, -- cgit v1.2.3-54-g00ecf