This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v3] 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:39:31 -0400
- Subject: [PATCH v3] sim: use socklen_t with accept()
- References: <m3fx3hsb5o.fsf@fleche.redhat.com>
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>
---
v3
- have dv-sockser.c declare socklen_t fallback
2010-03-30 Mike Frysinger <vapier@gentoo.org>
* configure.ac: Check for socklen_t.
* configure, config.in: Regenerated.
* dv-sockser.c: Typedef socklen_t as int when !HAVE_SOCKLEN_T.
(connected_p): Change addrlen type to socklen_t.
sim/common/config.in | 29 +++++++++++---------
sim/common/configure | 68 +++++++++++++++++++++++++++++++++++++++++++++++
sim/common/configure.ac | 5 +++
sim/common/dv-sockser.c | 6 +++-
4 files changed, 94 insertions(+), 14 deletions(-)
diff --git a/sim/common/config.in b/sim/common/config.in
index 6776827..6f93ff4 100644
--- a/sim/common/config.in
+++ b/sim/common/config.in
@@ -46,6 +46,9 @@
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
+/* Define to 1 if the system has the type `socklen_t'. */
+#undef HAVE_SOCKLEN_T
+
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -58,43 +61,43 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
-/* Define to 1 if st_atime is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_atime'. */
#undef HAVE_STRUCT_STAT_ST_ATIME
-/* Define to 1 if st_blksize is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_blksize'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
-/* Define to 1 if st_blocks is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_blocks'. */
#undef HAVE_STRUCT_STAT_ST_BLOCKS
-/* Define to 1 if st_ctime is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_ctime'. */
#undef HAVE_STRUCT_STAT_ST_CTIME
-/* Define to 1 if st_dev is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_dev'. */
#undef HAVE_STRUCT_STAT_ST_DEV
-/* Define to 1 if st_gid is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_gid'. */
#undef HAVE_STRUCT_STAT_ST_GID
-/* Define to 1 if st_ino is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_ino'. */
#undef HAVE_STRUCT_STAT_ST_INO
-/* Define to 1 if st_mode is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_mode'. */
#undef HAVE_STRUCT_STAT_ST_MODE
-/* Define to 1 if st_mtime is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_mtime'. */
#undef HAVE_STRUCT_STAT_ST_MTIME
-/* Define to 1 if st_nlink is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_nlink'. */
#undef HAVE_STRUCT_STAT_ST_NLINK
-/* Define to 1 if st_rdev is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_rdev'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
-/* Define to 1 if st_size is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_size'. */
#undef HAVE_STRUCT_STAT_ST_SIZE
-/* Define to 1 if st_uid is a member of struct stat. */
+/* Define to 1 if `struct stat' is a member of `st_uid'. */
#undef HAVE_STRUCT_STAT_ST_UID
/* Define to 1 if you have the <sys/mman.h> header file. */
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..03d49da 100644
--- a/sim/common/dv-sockser.c
+++ b/sim/common/dv-sockser.c
@@ -55,6 +55,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "dv-sockser.h"
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t;
+#endif
+
/* Get definitions for both O_NONBLOCK and O_NDELAY. */
#ifndef O_NDELAY
@@ -243,7 +247,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