Skip to content

Conversation

@oreo639
Copy link

@oreo639 oreo639 commented Mar 16, 2025

When compiling with gcc14 and musl, the following error is produced:

libndp.c: In function 'mysendto6':
libndp.c:212:50: error: passing argument 5 of 'sendto' from incompatible pointer type [-Wincompatible-pointer-types]
  212 |         ret = sendto(sockfd, buf, buflen, flags, &sin6, sizeof(sin6));
      |                                                  ^~~~~
      |                                                  |
      |                                                  struct sockaddr_in6 *
In file included from libndp.c:27:
/usr/include/sys/socket.h:343:49: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_in6 *'
  343 | ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~

In POSIX, sendto() takes a sockaddr pointer:
https://pubs.opengroup.org/onlinepubs/009604499/functions/sendto.html

While glibc uses the gcc __transparent_union__ extension to mark them as compatible types, musl does not, as such we need to explicitly cast the pointer to tell the compiler that it is fine.

#25

When compiling with gcc14 and musl, the following error is produced:
libndp.c: In function 'mysendto6':
libndp.c:212:50: error: passing argument 5 of 'sendto' from incompatible pointer type [-Wincompatible-pointer-types]
  212 |         ret = sendto(sockfd, buf, buflen, flags, &sin6, sizeof(sin6));
      |                                                  ^~~~~
      |                                                  |
      |                                                  struct sockaddr_in6 *
In file included from libndp.c:27:
/usr/include/sys/socket.h:343:49: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_in6 *'
  343 | ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~~~

In POSIX, sendto() takes a sockaddr pointer:
https://pubs.opengroup.org/onlinepubs/009604499/functions/sendto.html

While glibc uses the gcc __transparent_union__ extension to mark them as
compatible types, musl does not, as such we need to explicitly cast the pointer
to tell the compiler that it is fine.
@oreo639
Copy link
Author

oreo639 commented Mar 16, 2025

Submitted to the mailing list (waiting moderator approval): https://lists.fedorahosted.org/archives/list/libndp@lists.fedorahosted.org/latest

arnout pushed a commit to buildroot/buildroot that referenced this pull request Jun 17, 2025
Patch has been pending upstream for a while [1], Alpine has merged an
older version that includes some whitespace damage but is functionally
equivalent.

[1] jpirko/libndp#29

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Signed-off-by: Julien Olivain <ju.o@free.fr>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Jun 26, 2025
Patch has been pending upstream for a while [1], Alpine has merged an
older version that includes some whitespace damage but is functionally
equivalent.

[1] jpirko/libndp#29

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 0c2aa35)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
arnout pushed a commit to buildroot/buildroot that referenced this pull request Jun 26, 2025
Patch has been pending upstream for a while [1], Alpine has merged an
older version that includes some whitespace damage but is functionally
equivalent.

[1] jpirko/libndp#29

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 0c2aa35)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant