From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v3] sim: use socklen_t with accept()
Date: Tue, 30 Mar 2010 22:39:00 -0000 [thread overview]
Message-ID: <1269988771-1940-1-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <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"
\f
+#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
next prev parent reply other threads:[~2010-03-30 22:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 19:38 [PATCH] " Mike Frysinger
2010-03-30 16:11 ` Tom Tromey
2010-03-30 18:42 ` Andreas Schwab
2010-03-30 22:08 ` [PATCH v2] " Mike Frysinger
2010-03-30 22:22 ` Tom Tromey
2010-03-30 22:39 ` Mike Frysinger [this message]
2010-03-30 23:04 ` [PATCH v3] " Tom Tromey
2010-03-30 22:39 ` [PATCH v2] " Mike Frysinger
2010-03-30 23:03 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1269988771-1940-1-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox