Re: [PATCH 2/2] src/locktest: add missing struct cast with syscall getsockname()

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



On Tue, Mar 04, 2025 at 12:21:19PM +0000, Luis Henriques wrote:
> The usage of variable 'myAddr' (struct sockaddr_in) is being casted into a
> 'struct sockaddr' when used with bind() and with connect().  This patch
> adds that cast when used with getsockname() as well, otherwise we'll get the
> following error:
> 
> locktest.c: In function 'main':
> locktest.c:1155:39: error: passing argument 2 of 'getsockname' from incompatible pointer type [-Wincompatible-pointer-types]
>  1155 |                 if (getsockname(s_fd, &myAddr, &addr_len)) {
>       |                                       ^~~~~~~
>       |                                       |
>       |                                       struct sockaddr_in *
> In file included from /usr/include/fortify/sys/socket.h:23,
>                  from locktest.c:19:
> /usr/include/sys/socket.h:391:23: note: expected 'struct sockaddr * restrict' but argument is of type 'struct sockaddr_in *'
>   391 | int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
>       |                       ^
> 
> Signed-off-by: Luis Henriques <luis@xxxxxxxxxx>
> ---


[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux