]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: topolicy/ioctl: use union for multiple data types
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 8 Jan 2023 03:08:09 +0000 (03:08 +0000)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 8 Jan 2023 16:28:48 +0000 (16:28 +0000)
libblkid/src/topology/ioctl.c

index b8fce4129d240a64c730342d5628ca5ca20923ca..a7045055fc1b2861d9328b2136d7e63347351cc4 100644 (file)
@@ -46,15 +46,18 @@ static int probe_ioctl_tp(blkid_probe pr,
        for (i = 0; i < ARRAY_SIZE(topology_vals); i++) {
                const struct topology_val *val = &topology_vals[i];
                int rc = 1;
-               unsigned int data;
+               union {
+                       unsigned long ul;
+                       int i;
+               } data;
 
                if (ioctl(pr->fd, val->ioc, &data) == -1)
                        goto nothing;
 
                if (val->set_int)
-                       rc = val->set_int(pr, (int) data);
+                       rc = val->set_int(pr, data.i);
                else
-                       rc = val->set_ulong(pr, (unsigned long) data);
+                       rc = val->set_ulong(pr, data.ul);
                if (rc)
                        goto err;
        }