From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
Fernanda Ma'rouf <[email protected]>,
Pavel Begunkov <[email protected]>,
io-uring Mailing List <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Dylan Yudaken <[email protected]>,
Facebook Kernel Team <[email protected]>
Subject: [PATCH liburing] examples/io_uring-udp: Use a proper cast for `(struct sockaddr *)` argument
Date: Tue, 26 Jul 2022 23:44:59 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
From: Ammar Faizi <[email protected]>
Sometimes the compiler accepts `(struct sockaddr_in *)` and
`(struct sockaddr_in6 *)` to be passed in to `(struct sockaddr *)`
without a cast. But not all compilers agree with that. Building with
clang 13.0.1 yields the following errors:
io_uring-udp.c:134:18: error: incompatible pointer types passing \
'struct sockaddr_in6 *' to parameter of type 'const struct sockaddr *' \
[-Werror,-Wincompatible-pointer-types
io_uring-udp.c:142:18: error: incompatible pointer types passing \
'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' \
[-Werror,-Wincompatible-pointer-types]
Explicitly cast the pointer to (struct sockaddr *) to avoid this error.
Cc: Dylan Yudaken <[email protected]>
Cc: Facebook Kernel Team <[email protected]>
Fixes: 61d472b51e761e61cbf46caea40aaf40d8ed1484 ("add an example for a UDP server")
Signed-off-by: Ammar Faizi <[email protected]>
---
examples/io_uring-udp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/io_uring-udp.c b/examples/io_uring-udp.c
index 77472df..b4ef0a3 100644
--- a/examples/io_uring-udp.c
+++ b/examples/io_uring-udp.c
@@ -131,7 +131,7 @@ static int setup_sock(int af, int port)
.sin6_addr = IN6ADDR_ANY_INIT
};
- ret = bind(fd, &addr6, sizeof(addr6));
+ ret = bind(fd, (struct sockaddr *) &addr6, sizeof(addr6));
} else {
struct sockaddr_in addr = {
.sin_family = af,
@@ -139,7 +139,7 @@ static int setup_sock(int af, int port)
.sin_addr = { INADDR_ANY }
};
- ret = bind(fd, &addr, sizeof(addr));
+ ret = bind(fd, (struct sockaddr *) &addr, sizeof(addr));
}
if (ret) {
base-commit: 61d472b51e761e61cbf46caea40aaf40d8ed1484
--
Ammar Faizi
next reply other threads:[~2022-07-26 16:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-26 16:44 Ammar Faizi [this message]
2022-07-26 16:47 ` [PATCH liburing] examples/io_uring-udp: Use a proper cast for `(struct sockaddr *)` argument Jens Axboe
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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