]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Consistently use socklen_t for getsockname, getsockopt etc.
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 10 Feb 2016 13:11:28 +0000 (13:11 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 11 Feb 2016 01:04:53 +0000 (02:04 +0100)
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),
<http://manpages.debian.org/cgi-bin/man.cgi?query=accept&sektion=2>.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
dbus/dbus-sysdeps-unix.c
tools/dbus-print-message.c

index 50ca60a212d69ed1e62eed33272314bb58cb0e46..3abef52587114ad1e5077c029b527e0907417529 100644 (file)
@@ -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))
index b747e877d3dd5c19c970273c108793b1343f51df..547f72f86c826542acb89caf326cf29600fb81a9 100644 (file)
 #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