[PATCH liburing 2/3] test/send_recv: Use proper cast for (struct sockaddr *) argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Tested-by: Louvian Lyndal <louvianlyndal@xxxxxxxxx>
Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxx>
---
 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




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux