From 39a121ddbcf83314c5a75e23671acbc6600292ce Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 8 Dec 2021 10:56:21 +0100 Subject: [PATCH] libdm: correct version check If there ever would be API version 5, these check would give incorrect results. --- device_mapper/ioctl/libdm-iface.c | 6 ++---- libdm/ioctl/libdm-iface.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c index 533bb9eea..925f18c6b 100644 --- a/device_mapper/ioctl/libdm-iface.c +++ b/device_mapper/ioctl/libdm-iface.c @@ -616,8 +616,7 @@ int dm_check_version(void) int dm_cookie_supported(void) { return (dm_check_version() && - _dm_version >= 4 && - _dm_version_minor >= 15); + ((_dm_version == 4) ? _dm_version_minor >= 15 : _dm_version > 4)); } static int _dm_inactive_supported(void) @@ -1441,8 +1440,7 @@ static int _udev_complete(struct dm_task *dmt) static int _check_uevent_generated(struct dm_ioctl *dmi) { if (!dm_check_version() || - _dm_version < 4 || - _dm_version_minor < 17) + ((_dm_version == 4) ? _dm_version_minor < 17 : _dm_version < 4)) /* can't check, assume uevent is generated */ return 1; diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c index 28589a15c..a3a1bdc66 100644 --- a/libdm/ioctl/libdm-iface.c +++ b/libdm/ioctl/libdm-iface.c @@ -609,8 +609,7 @@ int dm_check_version(void) int dm_cookie_supported(void) { return (dm_check_version() && - _dm_version >= 4 && - _dm_version_minor >= 15); + ((_dm_version == 4) ? _dm_version_minor >= 15 : _dm_version > 4)); } static int _dm_inactive_supported(void) @@ -1436,8 +1435,7 @@ static int _udev_complete(struct dm_task *dmt) static int _check_uevent_generated(struct dm_ioctl *dmi) { if (!dm_check_version() || - _dm_version < 4 || - _dm_version_minor < 17) + ((_dm_version == 4) ? _dm_version_minor < 17 : _dm_version < 4)) /* can't check, assume uevent is generated */ return 1;