From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
Dylan Yudaken <[email protected]>,
Facebook Kernel Team <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
io-uring Mailing List <[email protected]>
Subject: [PATCH liburing] test/helpers: Use a proper cast for `(struct sockaddr *)` argument
Date: Sun, 3 Jul 2022 13:44:05 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
From: Ammar Faizi <[email protected]>
Sometimes the compiler accepts (struct sockaddr_in *) 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 error:
error: incompatible pointer types passing 'struct sockaddr_in *' to \
parameter of type 'struct sockaddr *' [-Werror,-Wincompatible-pointer-types]
Explicitly cast the pointer to (struct sockaddr *) to avoid this error.
Cc: [email protected]
Cc: Dylan Yudaken <[email protected]>
Fixes: 9167905ca187064ba1d9ac4c8bb8484157bef86b ("add t_create_socket_pair")
Signed-off-by: Ammar Faizi <[email protected]>
---
test/helpers.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/test/helpers.c b/test/helpers.c
index 3660cc0..0146533 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -190,26 +190,28 @@ int t_create_socket_pair(int fd[2], bool stream)
goto errno_cleanup;
}
- if (getsockname(fd[0], &serv_addr, (socklen_t *)&paddrlen)) {
+ if (getsockname(fd[0], (struct sockaddr *)&serv_addr,
+ (socklen_t *)&paddrlen)) {
fprintf(stderr, "getsockname failed\n");
goto errno_cleanup;
}
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
- if (connect(fd[1], &serv_addr, paddrlen)) {
+ if (connect(fd[1], (struct sockaddr *)&serv_addr, paddrlen)) {
fprintf(stderr, "connect failed\n");
goto errno_cleanup;
}
if (!stream) {
/* connect the other udp side */
- if (getsockname(fd[1], &serv_addr, (socklen_t *)&paddrlen)) {
+ if (getsockname(fd[1], (struct sockaddr *)&serv_addr,
+ (socklen_t *)&paddrlen)) {
fprintf(stderr, "getsockname failed\n");
goto errno_cleanup;
}
inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr);
- if (connect(fd[0], &serv_addr, paddrlen)) {
+ if (connect(fd[0], (struct sockaddr *)&serv_addr, paddrlen)) {
fprintf(stderr, "connect failed\n");
goto errno_cleanup;
}
base-commit: 98c14a04e2c0dcdfbb71372a1a209ed889fb3e4d
--
Ammar Faizi
next reply other threads:[~2022-07-03 6:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-03 6:44 Ammar Faizi [this message]
2022-07-03 13:00 ` [PATCH liburing] test/helpers: 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] \
/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