netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] connector, linux++: fix <uapi/linux/cn_proc.h> header
@ 2024-01-23 10:16 Alexey Dobriyan
  2024-01-24  8:40 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2024-01-23 10:16 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni; +Cc: netdev

Rules around enums are stricter in C++, they decay to ints just as
easily but don't convert back to enums:

	#define PROC_EVENT_ALL (PROC_EVENT_FORK|...)
	enum proc_cn_event ev_type;
	ev_type &= PROC_EVENT_ALL;

main.cc: In function ‘proc_cn_event valid_event(proc_cn_event)’:
main.cc:91:17: error: invalid conversion from ‘unsigned int’ to ‘proc_cn_event’ [-fpermissive]
   91 |         ev_type &= PROC_EVENT_ALL;
      |                 ^
      |                 |
      |                 unsigned int

Use casts so that both C and C++ compilers are satisfied.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

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

--- 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.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-24  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 10:16 [PATCH 2/2] connector, linux++: fix <uapi/linux/cn_proc.h> header Alexey Dobriyan
2024-01-24  8:40 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).