Skip to contentSkip to conversation

devlink: use _BITUL() macro instead of BIT() in the UAPI header

PATCH Applied Tobias Klauser 3 participants 3 messages Dec 15, 2020 – Jan 5, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devlink: use _BITUL() macro instead of BIT() in the UAPI header

The BIT() macro is not available for the UAPI headers. Moreover, it can be defined differently in user space headers. Thus, replace its usage with the _BITUL() macro which is already used in other macro definitions in <linux/devlink.h>.

Fixes dc64cc7c6310 ("devlink: Add devlink reload limit option")
---
 include/uapi/linux/devlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/devlink.h +1 -1
index 5203f54a2be1..cf89c318f2ac 100644
@@ -322,7 +322,7 @@ enum devlink_reload_limit {
 	DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX - 1
 };
 
-#define DEVLINK_RELOAD_LIMITS_VALID_MASK (BIT(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
+#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
 
 enum devlink_attr {
 	/* don't change the order or add anything between, this is ABI! */
Signature · 1 line
2.27.0
#1 lore raw
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 9 lines · On Tue, 15 Dec 2020 11:25:31 +0100 you wrote:

The BIT() macro is not available for the UAPI headers. Moreover, it can be defined differently in user space headers. Thus, replace its usage with the _BITUL() macro which is already used in other macro definitions in <linux/devlink.h>.

Fixes dc64cc7c6310 ("devlink: Add devlink reload limit option")

[...]

Here is the summary with links:
- [net-next] devlink: use _BITUL() macro instead of BIT() in the UAPI header

    https://git.kernel.org/netdev/net/c/75f4d4544db9

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Reviewed-by on v1 1/1
#2 lore raw
In reply to Tobias Klauser
Quoted 7 lines · Tobias Klauser

The BIT() macro is not available for the UAPI headers. Moreover, it can be defined differently in user space headers. Thus, replace its usage with the _BITUL() macro which is already used in other macro definitions in <linux/devlink.h>.

Fixes dc64cc7c6310 ("devlink: Add devlink reload limit option")

Yep, this is correct, and we ran into this exact issue a few months ago with the flash update parameters work. Wonder how difficult it would be to get something like checkpatch.pl or another utility to complain about using BIT() macros in UAPI..?

Unfortunately this is easy to overlook because the kernel side code almost always has BIT defined, so you won't get a compilation failure until you try to use the uapi header in a userspace program.

Quoted 18 lines
---
 include/uapi/linux/devlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/devlink.h +1 -1
index 5203f54a2be1..cf89c318f2ac 100644
@@ -322,7 +322,7 @@ enum devlink_reload_limit {
 	DEVLINK_RELOAD_LIMIT_MAX = __DEVLINK_RELOAD_LIMIT_MAX - 1
 };
 
-#define DEVLINK_RELOAD_LIMITS_VALID_MASK (BIT(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
+#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
 
 enum devlink_attr {
 	/* don't change the order or add anything between, this is ABI! */