]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
storagetm: ensure we pass dev_t* to sd_device_get_devnum
authorMike Gilbert <floppym@gentoo.org>
Fri, 29 Dec 2023 18:45:26 +0000 (13:45 -0500)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Jan 2024 20:37:25 +0000 (05:37 +0900)
On MIPS32 OABI, st_rdev is unsigned long, not dev_t. Use a temporary
variable to avoid an incompatible pointer.

Bug: https://bugs.gentoo.org/920576
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21278
Fixes: https://github.com/systemd/systemd/issues/30626
src/storagetm/storagetm.c

index b28924a8b456eaf73dfe24a8a0d4d419c275a3c9..e0ca51d16d7f71a5a90c1f3856f5681bd5590e80 100644 (file)
@@ -950,9 +950,14 @@ static int device_added(Context *c, sd_device *device) {
                 .st_mode = S_IFBLK,
         };
 
-        r = sd_device_get_devnum(device, &lookup_key.st_rdev);
+        /* MIPS OABI declares st_rdev as unsigned long instead of dev_t.
+         * Use a temp var to avoid passing an incompatible pointer.
+         * https://sourceware.org/bugzilla/show_bug.cgi?id=21278 */
+        dev_t devnum;
+        r = sd_device_get_devnum(device, &devnum);
         if (r < 0)
                 return log_device_error_errno(device, r, "Failed to get major/minor from device: %m");
+        lookup_key.st_rdev = devnum;
 
         if (hashmap_contains(c->subsystems, &lookup_key)) {
                 log_debug("Device '%s' already seen.", devname);
@@ -1006,9 +1011,14 @@ static int device_removed(Context *c, sd_device *device) {
                 .st_mode = S_IFBLK,
         };
 
-        r = sd_device_get_devnum(device, &lookup_key.st_rdev);
+        /* MIPS OABI declares st_rdev as unsigned long instead of dev_t.
+         * Use a temp var to avoid passing an incompatible pointer.
+         * https://sourceware.org/bugzilla/show_bug.cgi?id=21278 */
+        dev_t devnum;
+        r = sd_device_get_devnum(device, &devnum);
         if (r < 0)
                 return log_device_error_errno(device, r, "Failed to get major/minor from device: %m");
+        lookup_key.st_rdev = devnum;
 
         NvmeSubsystem *s = hashmap_remove(c->subsystems, &lookup_key);
         if (!s)