]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
src/locktest: add missing struct cast with syscall getsockname()
authorLuis Henriques <luis@igalia.com>
Tue, 4 Mar 2025 12:21:19 +0000 (12:21 +0000)
committerZorro Lang <zlang@kernel.org>
Mon, 10 Mar 2025 06:54:05 +0000 (14:54 +0800)
commit9594473fffb7f1b2eba80068ba7a33cb7a50f990
treed8cbb8a8b1fcff9a2b1d7d482c4b63fa4ad3da35
parent90a2be3c9e445ae31d90499b3cffc3327037149a
src/locktest: add missing struct cast with syscall getsockname()

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@igalia.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/locktest.c