All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ammar Faizi <ammarfaizi2@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, Ammar Faizi <ammarfaizi2@gmail.com>,
	Louvian Lyndal <louvianlyndal@gmail.com>
Subject: [PATCH liburing 2/3] test/send_recv: Use proper cast for (struct sockaddr *) argument
Date: Wed, 15 Sep 2021 15:11:57 +0700	[thread overview]
Message-ID: <91812264f5600e1a460203d5297eb43aa978f9bf.1631692342.git.ammarfaizi2@gmail.com> (raw)
In-Reply-To: <2d53ef3f50713749511865a7f89e27c5378e316d.1631692342.git.ammarfaizi2@gmail.com>

This commit fixes build for armv8l.

Sometimes the compiler accepts (struct sockaddr_in *) to be passed to
(struct sockaddr *) without cast. But not all compilers agree with that.

Louvian found the following warning on armv8l:
```
  send_recv.c:203:24: warning: incompatible pointer types passing 'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' [-Wincompatible-pointer-types]
          ret = connect(sockfd, &saddr, sizeof(saddr));
                                ^~~~~~
  /usr/include/sys/socket.h:308:59: note: passing argument to parameter '__addr' here
  __socketcall int connect(int __fd, const struct sockaddr* __addr, socklen_t __addr_length);
                                                            ^
  1 warning generated.
```

Fix this by casting the second argument to (struct sockaddr *).

Reported-by: Louvian Lyndal <louvianlyndal@gmail.com>
Tested-by: Louvian Lyndal <louvianlyndal@gmail.com>
Signed-off-by: Ammar Faizi <ammarfaizi2@gmail.com>
---
 test/send_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/send_recv.c b/test/send_recv.c
index 38ae27f..1ee0234 100644
--- a/test/send_recv.c
+++ b/test/send_recv.c
@@ -200,7 +200,7 @@ static int do_send(void)
 		return 1;
 	}
 
-	ret = connect(sockfd, &saddr, sizeof(saddr));
+	ret = connect(sockfd, (struct sockaddr *)&saddr, sizeof(saddr));
 	if (ret < 0) {
 		perror("connect");
 		return 1;
-- 
2.30.2


  reply	other threads:[~2021-09-15  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15  8:11 [PATCH liburing 0/3] Fix build and add /test/output dir to .gitignore Ammar Faizi
2021-09-15  8:11 ` [PATCH liburing 1/3] test/io_uring_setup: Don't use `__errno` as local variable name Ammar Faizi
2021-09-15  8:11   ` Ammar Faizi [this message]
2021-09-15  8:11   ` [PATCH liburing 3/3] .gitignore: add `/test/output/` Ammar Faizi
2021-09-15 12:41 ` [PATCH liburing 0/3] Fix build and add /test/output dir to .gitignore 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 \
    --in-reply-to=91812264f5600e1a460203d5297eb43aa978f9bf.1631692342.git.ammarfaizi2@gmail.com \
    --to=ammarfaizi2@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=louvianlyndal@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.