]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: do not use downgrade-to-bool feature 18382/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Jan 2021 14:57:33 +0000 (23:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 26 Jan 2021 15:01:02 +0000 (00:01 +0900)
src/libsystemd/sd-device/sd-device.c

index d1aa3282bf4bfc394323abc757942760f790e31d..00df63edb3aab3b32b0bb64ff8bda5193fe2adb6 100644 (file)
@@ -231,8 +231,7 @@ _public_ int sd_device_new_from_syspath(sd_device **ret, const char *syspath) {
 }
 
 _public_ int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum) {
-        char *syspath;
-        char id[DECIMAL_STR_MAX(unsigned) * 2 + 1];
+        char id[DECIMAL_STR_MAX(unsigned) * 2 + 1], *syspath;
 
         assert_return(ret, -EINVAL);
         assert_return(IN_SET(type, 'b', 'c'), -EINVAL);
@@ -399,7 +398,7 @@ int device_set_devmode(sd_device *device, const char *_devmode) {
 }
 
 int device_set_devnum(sd_device *device, const char *major, const char *minor) {
-        unsigned maj = 0, min = 0;
+        unsigned maj, min = 0;
         int r;
 
         assert(device);
@@ -408,7 +407,7 @@ int device_set_devnum(sd_device *device, const char *major, const char *minor) {
         r = safe_atou(major, &maj);
         if (r < 0)
                 return r;
-        if (!maj)
+        if (maj == 0)
                 return 0;
 
         if (minor) {