2024-05-10 15:50:13

by Matt Jan

[permalink] [raw]
Subject: [PATCH] connector: Fix invalid conversion in cn_proc.h

From: Matt Jan <[email protected]>

The implicit conversion from unsigned int to enum
proc_cn_event is invalid, so explicitly cast it
for compilation in a C++ compiler.
/usr/include/linux/cn_proc.h: In function 'proc_cn_event valid_event(proc_cn_event)':
/usr/include/linux/cn_proc.h:72:17: error: invalid conversion from 'unsigned int' to 'proc_cn_event' [-fpermissive]
72 | ev_type &= PROC_EVENT_ALL;
| ^
| |
| unsigned int

Signed-off-by: Matt Jan <[email protected]>
---
include/uapi/linux/cn_proc.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h
index f2afb7cc4926..22f9419498ca 100644
--- a/include/uapi/linux/cn_proc.h
+++ b/include/uapi/linux/cn_proc.h
@@ -69,8 +69,7 @@ struct proc_input {

static inline enum proc_cn_event valid_event(enum proc_cn_event ev_type)
{
- ev_type &= PROC_EVENT_ALL;
- return ev_type;
+ return (enum proc_cn_event) (ev_type & PROC_EVENT_ALL);
}

/*
--
2.25.1



2024-05-14 00:54:08

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] connector: Fix invalid conversion in cn_proc.h

On Fri, 10 May 2024 23:49:19 +0800 Matt Jan wrote:
> From: Matt Jan <[email protected]>
>
> The implicit conversion from unsigned int to enum
> proc_cn_event is invalid, so explicitly cast it
> for compilation in a C++ compiler.
> /usr/include/linux/cn_proc.h: In function 'proc_cn_event valid_event(proc_cn_event)':
> /usr/include/linux/cn_proc.h:72:17: error: invalid conversion from 'unsigned int' to 'proc_cn_event' [-fpermissive]
> 72 | ev_type &= PROC_EVENT_ALL;
> | ^
> | |
> | unsigned int
>
> Signed-off-by: Matt Jan <[email protected]>

Why not. But please fix the checkpatch warning:

CHECK: No space is necessary after a cast
#36: FILE: include/uapi/linux/cn_proc.h:72:
+ return (enum proc_cn_event) (ev_type & PROC_EVENT_ALL);
--
pw-bot: cr

2024-05-14 04:11:07

by Matt Jan

[permalink] [raw]
Subject: [PATCH v2] connector: Fix invalid conversion in cn_proc.h

The implicit conversion from unsigned int to enum
proc_cn_event is invalid, so explicitly cast it
for compilation in a C++ compiler.
/usr/include/linux/cn_proc.h: In function 'proc_cn_event valid_event(proc_cn_event)':
/usr/include/linux/cn_proc.h:72:17: error: invalid conversion from 'unsigned int' to 'proc_cn_event' [-fpermissive]
72 | ev_type &= PROC_EVENT_ALL;
| ^
| |
| unsigned int

Signed-off-by: Matt Jan <[email protected]>
---
change in v2:
fix: remove space after cast

include/uapi/linux/cn_proc.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h
index f2afb7cc4926..18e3745b86cd 100644
--- a/include/uapi/linux/cn_proc.h
+++ b/include/uapi/linux/cn_proc.h
@@ -69,8 +69,7 @@ struct proc_input {

static inline enum proc_cn_event valid_event(enum proc_cn_event ev_type)
{
- ev_type &= PROC_EVENT_ALL;
- return ev_type;
+ return (enum proc_cn_event)(ev_type & PROC_EVENT_ALL);
}

/*
--
2.25.1


2024-05-24 09:40:40

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH v2] connector: Fix invalid conversion in cn_proc.h

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

On Tue, 14 May 2024 12:10:46 +0800 you wrote:
> The implicit conversion from unsigned int to enum
> proc_cn_event is invalid, so explicitly cast it
> for compilation in a C++ compiler.
> /usr/include/linux/cn_proc.h: In function 'proc_cn_event valid_event(proc_cn_event)':
> /usr/include/linux/cn_proc.h:72:17: error: invalid conversion from 'unsigned int' to 'proc_cn_event' [-fpermissive]
> 72 | ev_type &= PROC_EVENT_ALL;
> | ^
> | |
> | unsigned int
>
> [...]

Here is the summary with links:
- [v2] connector: Fix invalid conversion in cn_proc.h
https://git.kernel.org/netdev/net/c/06e785aeb9ea

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