From: Alexey Dobriyan <adobriyan@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/2] connector, linux++: fix <uapi/linux/cn_proc.h> header
Date: Tue, 23 Jan 2024 13:16:46 +0300 [thread overview]
Message-ID: <3878dc5a-9046-4d7a-bf9e-70dcdc5d9265@p183> (raw)
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
next reply other threads:[~2024-01-23 10:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 10:16 Alexey Dobriyan [this message]
2024-01-24 8:40 ` [PATCH 2/2] connector, linux++: fix <uapi/linux/cn_proc.h> header Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3878dc5a-9046-4d7a-bf9e-70dcdc5d9265@p183 \
--to=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).