OSDN Git Service

sim: use socklen_t with accept()
authorvapier <vapier>
Wed, 31 Mar 2010 08:09:48 +0000 (08:09 +0000)
committervapier <vapier>
Wed, 31 Mar 2010 08:09:48 +0000 (08:09 +0000)
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().

sim/common/ChangeLog
sim/common/config.in
sim/common/configure
sim/common/configure.ac
sim/common/dv-sockser.c

index 3edb464..d83136b 100644 (file)
@@ -1,5 +1,11 @@
 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.
+
+2010-03-30  Mike Frysinger  <vapier@gentoo.org>
+
        * sim-utils.c (sim_io_eprintf_cpu): Use %s with printf string.
        * sim-hw.c (hw_option_handler): Likewise.
 
index 6776827..6f93ff4 100644 (file)
@@ -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
 
 /* 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. */
index c71cf3d..fdf9281 100755 (executable)
@@ -1852,6 +1852,60 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
 
 } # ac_fn_c_check_member
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -4563,6 +4617,20 @@ _ACEOF
 
 fi
 
+ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include <sys/types.h>
+#include <sys/socket.h>
+
+"
+if test "x$ac_cv_type_socklen_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_SOCKLEN_T 1
+_ACEOF
+
+
+fi
+
+
 ac_config_files="$ac_config_files Makefile"
 
 ac_config_commands="$ac_config_commands default"
index 5f5845a..39302c8 100644 (file)
@@ -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])
index 9195190..03d49da 100644 (file)
@@ -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;