Skip to contentSkip to conversation

connector: Fix invalid conversion in cn_proc.h

PATCH Superseded Matt Jan 3 participants 4 messages May 10, 2024 – May 24, 2024

Subsystems (2)
lore
Share & tools
lore

Matt Jan

author
#0 lore raw

PATCH 1/1 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
---
 include/uapi/linux/cn_proc.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/uapi/linux/cn_proc.h +1 -2
index f2afb7cc4926..22f9419498ca 100644
@@ -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);
 }
 
 /*
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 7 lines · 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]

Quoted 6 lines
   72 |         ev_type &= PROC_EVENT_ALL;
      |                 ^
      |                 |
      |                 unsigned int

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);

Signature · 1 line
pw-bot: cr
author
#2 lore raw

PATCH v2 1/1 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

---
change in v2:
fix: remove space after cast

 include/uapi/linux/cn_proc.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/uapi/linux/cn_proc.h +1 -2
index f2afb7cc4926..18e3745b86cd 100644
@@ -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);
 }
 
 /*
Signature · 1 line
2.25.1
#3 lore raw
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

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

Quoted 11 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html