This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2] sim: use socklen_t with accept()
- From: Mike Frysinger <vapier at gentoo dot org>
- To: gdb-patches at sourceware dot org
- Date: Tue, 30 Mar 2010 18:07:55 -0400
- Subject: [PATCH v2] sim: use socklen_t with accept()
- References: <m2y6h9tzwl.fsf@igel.home>
The accept() function takes a socklen_t, not an int. Using an int causes:
dv-sockser.c: In function 'connected_p':
dv-sockser.c:273: warning: pointer targets in passing argument 3
of 'accept' differ in signedness
So use the same socklen_t detection code as gdb and convert the accept().
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
- pull in socklen_t configure checks as suggested by people
2010-03-30 Mike Frysinger <vapier@gentoo.org>
* configure.ac: Check for socklen_t.
* configure, config.in: Regenerated.
* dv-sockser.c (connected_p): Change addrlen type to socklen_t.
Note: this config.in diffstat is larger because the regen tweaked the
comment style for a lot of defines ... not sure if this is correct
sim/common/config.in | 29 +++++++++++---------
sim/common/configure | 68 +++++++++++++++++++++++++++++++++++++++++++++++
sim/common/configure.ac | 5 +++
sim/common/dv-sockser.c | 2 +-
4 files changed, 90 insertions(+), 14 deletions(-)
diff --git a/sim/common/configure.ac b/sim/common/configure.ac
index 5f5845a..39302c8 100644
--- a/sim/common/configure.ac
+++ b/sim/common/configure.ac
@@ -49,5 +49,10 @@ AC_CHECK_MEMBERS([[struct stat.st_dev], [struct stat.st_ino],
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif]])
+AC_CHECK_TYPES(socklen_t, [], [],
+[#include <sys/types.h>
+#include <sys/socket.h>
+])
+
AC_OUTPUT(Makefile,
[case x$CONFIG_HEADERS in xcconfig.h:config.in) echo > stamp-h ;; esac])
diff --git a/sim/common/dv-sockser.c b/sim/common/dv-sockser.c
index 9195190..c584fc7 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -243,7 +243,7 @@ connected_p (SIM_DESC sd)
struct timeval tv;
fd_set readfds;
struct sockaddr sockaddr;
- int addrlen;
+ socklen_t addrlen;
if (sockser_listen_fd == -1)
return 0;
--
1.7.0.2