blkid-print: fix partition path for /dev/sdX devices 93/299893/1
authorJacek Kryszyn <j.kryszyn@samsung.com>
Wed, 11 Oct 2023 12:18:20 +0000 (14:18 +0200)
committerJacek Kryszyn <j.kryszyn@samsung.com>
Wed, 11 Oct 2023 12:18:20 +0000 (14:18 +0200)
This change fixes output in case of partitions on /dev/sdX devices.
Previously comparison of a device name with the "dev/sd" string
using strncmp would always return a value different than 0.

Change-Id: I77c471d174e87a70401cddab5464b8c1f671dc3d

src/blkid-print/blkid-print.c

index bbb3f98..17addaf 100644 (file)
@@ -118,7 +118,7 @@ int main(int argc, char *argv[]) {
        char part_path[PATH_MAX];
        // /dev/sda1 vs /dev/mmcblk0p1 /dev/nvme0n1p1
        // no_separator vs "p" separator
-       if (strncmp("/dev/sd", device_name, strlen(device_name) + 1) == 0)
+       if (strncmp("/dev/sd", device_name, strlen("/dev/sd")) == 0)
                snprintf(part_path, PATH_MAX, "%s%d", device_name, part_nr);
        else
                snprintf(part_path, PATH_MAX, "%sp%d", device_name, part_nr);