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;
}
}
f = fopen(dbfile, "re");
- if (f == NULL) {
- log_debug("no db file to read %s: %m\n", 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;
}
fclose(f);
- log_debug("device %p filled with db file data\n", udev_device);
+ log_debug("device %p filled with db file data", udev_device);
return 0;
}
/* path starts in sys */
if (!startswith(syspath, "/sys")) {
- log_debug("not in sys :%s\n", syspath);
+ log_debug("not in sys :%s", syspath);
errno = EINVAL;
return NULL;
}
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);
return NULL;
udev_device_set_syspath(udev_device, path);
- log_debug("device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
+ log_debug("device %p has devpath '%s'", udev_device, udev_device_get_devpath(udev_device));
return udev_device;
}
udev_device_add_property_from_string_parse(udev_device, environ[i]);
if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) {
- log_debug("missing values, invalid device\n");
+ log_debug("missing values, invalid device");
udev_device_unref(udev_device);
udev_device = NULL;
}