030-remove-MAX-a-b-macro-to-avoid-conflict-with-kernel.h.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From 8c19700558b154b4898e49014b9a9725dabadddb Mon Sep 17 00:00:00 2001
  2. From: Stefan Kalscheuer <[email protected]>
  3. Date: Sat, 31 May 2025 16:52:23 +0200
  4. Subject: [PATCH] remove MAX(a,b) macro to avoid conflict with
  5. kernel.h/minmax.h
  6. Building against recent kernel versions (noticed with 6.12) and -Werror
  7. can fail because a macro MAX(a,b) is already defined in minmax.h or
  8. kernel.h before 5.10.
  9. In file included from ../mwlwifi-2025.02.06~db97edf2/hif/fwcmd.h:23,
  10. from ../mwlwifi-2025.02.06~db97edf2/core.c:25:
  11. ../mwlwifi-2025.02.06~db97edf2/hif/hostcmd.h:1124:9: error: "MAX" redefined [-Werror]
  12. 1124 | #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  13. | ^~~
  14. In file included from usr/include/mac80211-backport/linux/minmax.h:4,
  15. from ./include/linux/kernel.h:28,
  16. from usr/include/mac80211-backport/linux/kernel.h:3,
  17. from ./include/linux/skbuff.h:13,
  18. from usr/include/mac80211-backport/linux/skbuff.h:3,
  19. from ./include/linux/if_ether.h:19,
  20. from usr/include/mac80211-backport/linux/if_ether.h:3,
  21. from ./include/linux/etherdevice.h:20,
  22. from usr/include/mac80211-backport/linux/etherdevice.h:3,
  23. from ../mwlwifi-2025.02.06~db97edf2/core.c:18:
  24. ./include/linux/minmax.h:330:9: note: this is the location of the previous definition
  25. 330 | #define MAX(a,b) __cmp(max,a,b)
  26. | ^~~
  27. This macro is not used anywhere else but in the very next line, so
  28. instead of adding conditionals, let's expand MAX_GROUP_PER_CHANNEL_RATE
  29. and drop the definition of MAX.
  30. Signed-off-by: Stefan Kalscheuer <[email protected]>
  31. ---
  32. hif/hostcmd.h | 3 +--
  33. 1 file changed, 1 insertion(+), 2 deletions(-)
  34. --- a/hif/hostcmd.h
  35. +++ b/hif/hostcmd.h
  36. @@ -1121,9 +1121,8 @@ struct hostcmd_cmd_get_fw_region_code_sc
  37. #define HAL_TRPC_ID_MAX_SC4 32
  38. #define MAX_GROUP_PER_CHANNEL_5G 39
  39. #define MAX_GROUP_PER_CHANNEL_2G 21
  40. -#define MAX(a, b) (((a) > (b)) ? (a) : (b))
  41. #define MAX_GROUP_PER_CHANNEL_RATE \
  42. - MAX(MAX_GROUP_PER_CHANNEL_5G, MAX_GROUP_PER_CHANNEL_2G)
  43. + ((MAX_GROUP_PER_CHANNEL_5G > MAX_GROUP_PER_CHANNEL_2G) ? MAX_GROUP_PER_CHANNEL_5G : MAX_GROUP_PER_CHANNEL_2G)
  44. struct channel_power_tbl_sc4 {
  45. u8 channel;