]> err.no Git - systemd/commitdiff
fix compiler warning
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 10 Jan 2012 18:37:41 +0000 (19:37 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 10 Jan 2012 18:37:41 +0000 (19:37 +0100)
src/libudev-util.c

index a795329f7caf5e104a1682b656787921231c705d..7e345f0fb671f38bb19f23905f7014b32e84afb1 100644 (file)
@@ -56,7 +56,7 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size)
         ssize_t len;
         int i;
         int back;
-        char *base;
+        char *base = NULL;
 
         len = readlink(syspath, link_target, sizeof(link_target));
         if (len <= 0 || len == (ssize_t)sizeof(link_target))
@@ -70,9 +70,11 @@ int util_resolve_sys_link(struct udev *udev, char *syspath, size_t size)
         for (i = 0; i <= back; i++) {
                 base = strrchr(syspath, '/');
                 if (base == NULL)
-                        return -1;
+                        return -EINVAL;
                 base[0] = '\0';
         }
+        if (base == NULL)
+                return -EINVAL;
         dbg(udev, "after moving back '%s'\n", syspath);
         util_strscpyl(base, size - (base - syspath), "/", &link_target[back * 3], NULL);
         return 0;