From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21089 invoked by alias); 30 Mar 2010 22:39:48 -0000 Received: (qmail 21075 invoked by uid 22791); 30 Mar 2010 22:39:47 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Mar 2010 22:39:42 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 133781B40E8 for ; Tue, 30 Mar 2010 22:39:40 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH v3] sim: use socklen_t with accept() Date: Tue, 30 Mar 2010 22:39:00 -0000 Message-Id: <1269988771-1940-1-git-send-email-vapier@gentoo.org> In-Reply-To: References: X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg01093.txt.bz2 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 --- v3 - have dv-sockser.c declare socklen_t fallback 2010-03-30 Mike Frysinger * 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 header file. */ #undef HAVE_STDINT_H @@ -58,43 +61,43 @@ /* Define to 1 if you have the 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 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 #endif]]) +AC_CHECK_TYPES(socklen_t, [], [], +[#include +#include +]) + 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 . */ #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