X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flibudev%2Flibudev-device.c;h=825a0e10f4fe31d8515d48f5005610f036320164;hp=fc7d9287217e77cab2b3900b721f1e3476addb59;hb=c4ef05484df942b6cc2037d33dd56cd209d1db9b;hpb=ff49bc3212cb07d850dcfd59940539773a0be26f diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index fc7d92872..825a0e10f 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -139,7 +139,7 @@ static int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex) char num[32]; udev_device->ifindex = ifindex; - snprintf(num, sizeof(num), "%u", ifindex); + snprintf(num, sizeof(num), "%d", ifindex); udev_device_add_property(udev_device, "IFINDEX", num); return 0; } @@ -534,10 +534,8 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile) } f = fopen(dbfile, "re"); - if (f == NULL) { - log_debug("no db file to read %s: %m", dbfile); - return -errno; - } + if (f == NULL) + return log_debug_errno(errno, "no db file to read %s: %m", dbfile); /* devices with a database entry are initialized */ udev_device->is_initialized = true; @@ -725,8 +723,13 @@ _public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, con return NULL; } else { /* everything else just needs to be a directory */ - if (stat(path, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode)) + if (stat(path, &statbuf) != 0) return NULL; + + if (!S_ISDIR(statbuf.st_mode)) { + errno = EISDIR; + return NULL; + } } udev_device = udev_device_new(udev);