From: Simon McVittie Date: Wed, 10 Feb 2016 13:11:28 +0000 (+0000) Subject: Consistently use socklen_t for getsockname, getsockopt etc. X-Git-Tag: dbus-1.11.2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15868d2a3957f4e5056544844f29629fae674b61;p=thirdparty%2Fdbus.git Consistently use socklen_t for getsockname, getsockopt etc. This fixes signedness mismatch warnings on platforms where socklen_t is unsigned, notably Linux (where it's an unsigned int). We still use int for the fallback case where the platform does not define socklen_t, because that was the traditional (pre-POSIX) type: for details see NOTES in Linux accept(2), . Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker --- diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 50ca60a21..3abef5258 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1905,7 +1905,7 @@ _dbus_read_credentials_socket (DBusSocket client_fd, #else struct ucred cr; #endif - int cr_len = sizeof (cr); + socklen_t cr_len = sizeof (cr); if (getsockopt (client_fd.fd, SOL_SOCKET, SO_PEERCRED, &cr, &cr_len) != 0) { @@ -4365,7 +4365,7 @@ _dbus_append_address_from_socket (DBusSocket fd, struct sockaddr_in6 ipv6; } socket; char hostip[INET6_ADDRSTRLEN]; - int size = sizeof (socket); + socklen_t size = sizeof (socket); DBusString path_str; if (getsockname (fd.fd, &socket.sa, &size)) diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index b747e877d..547f72f86 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -52,6 +52,10 @@ #endif #endif +#ifndef HAVE_SOCKLEN_T +#define socklen_t int +#endif + static const char* type_to_name (int message_type) { @@ -182,8 +186,8 @@ print_fd (int fd, int depth) struct sockaddr_in6 ipv6; } addr, peer; char hostip[INET6_ADDRSTRLEN]; - int addrlen = sizeof (addr); - int peerlen = sizeof (peer); + socklen_t addrlen = sizeof (addr); + socklen_t peerlen = sizeof (peer); int has_peer; /* Don't print the fd number: it is different in every process and since