modules: make COMPAT_LINUX_VERSION_CHECK_LT less tricky

The definition of COMPAT_LINUX_VERSION_CHECK_LT() macro lacks surrounding
paretheses so that negated tests like !COMPAT_LINUX_VERSION_CHECK_LT(...)
expand to something completely different. This could be worked around
easily by adding parentheses to each place the macro is used in an
expression but it makes much more sense to fix the macro definition so that
the macro does not serve as a trap.
This commit is contained in:
Michal Kubecek 2023-08-12 20:03:09 +02:00
parent 8a8ba0a9e4
commit 34855a4e8f
2 changed files with 4 additions and 4 deletions

View File

@ -118,11 +118,11 @@
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
/* Straight forward comparison if kernel version is 3.0.0 and beyond */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) LINUX_VERSION_CODE < KERNEL_VERSION (a, b, c)
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) (LINUX_VERSION_CODE < KERNEL_VERSION (a, b, c))
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 40)
/* Use b of the check to calculate corresponding c of kernel
* version to compare */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, (b + 40))
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) (LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, (b + 40)))
#else
/* This is anyways lesser than any 3.x versions */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) 1

View File

@ -118,11 +118,11 @@
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
/* Straight forward comparison if kernel version is 3.0.0 and beyond */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) LINUX_VERSION_CODE < KERNEL_VERSION (a, b, c)
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) (LINUX_VERSION_CODE < KERNEL_VERSION (a, b, c))
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 40)
/* Use b of the check to calculate corresponding c of kernel
* version to compare */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, (b + 40))
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) (LINUX_VERSION_CODE < KERNEL_VERSION (2, 6, (b + 40)))
#else
/* This is anyways lesser than any 3.x versions */
# define COMPAT_LINUX_VERSION_CHECK_LT(a, b, c) 1