From 049f178b805720908459208d32cd374a40a064fc Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Fri, 29 Dec 2023 13:45:26 -0500 Subject: [PATCH] storagetm: ensure we pass dev_t* to sd_device_get_devnum 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/storagetm/storagetm.c b/src/storagetm/storagetm.c index b28924a8b45..e0ca51d16d7 100644 --- a/src/storagetm/storagetm.c +++ b/src/storagetm/storagetm.c @@ -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) -- 2.47.3