From 3172063ead6b99611d049a59938808a6358f48a4 Mon Sep 17 00:00:00 2001 From: Greg Banks Date: Tue, 27 Jun 2006 20:55:07 +1000 Subject: [PATCH] Detect if glibc provides socklen_t and use that instead of int in those cases which generate compile warnings, e.g. the last argument of recvfrom(). --- configure.in | 2 ++ support/nfs/rpcmisc.c | 8 ++++++-- utils/statd/rmtcall.c | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 3f8fbb5..8459ef8 100644 --- a/configure.in +++ b/configure.in @@ -252,6 +252,8 @@ AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(size_t) +AC_CHECK_SIZEOF(socklen_t) + dnl ************************************************************* dnl Export some path names to config.h diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c index 8c94ad9..5b0a88f 100644 --- a/support/nfs/rpcmisc.c +++ b/support/nfs/rpcmisc.c @@ -34,6 +34,10 @@ #include #include "nfslib.h" +#if SIZEOF_SOCKLEN_T - 0 == 0 +#define socklen_t int +#endif + static void closedown(int sig); int makesock(int port, int proto); @@ -48,13 +52,13 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport) struct sockaddr_in saddr; SVCXPRT *transp; int sock; - int asize; + socklen_t asize; asize = sizeof(saddr); sock = 0; if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0 && saddr.sin_family == AF_INET) { - int ssize = sizeof (int); + socklen_t ssize = sizeof (int); int fdtype = 0; if (getsockopt(0, SOL_SOCKET, SO_TYPE, (char *)&fdtype, &ssize) == -1) diff --git a/utils/statd/rmtcall.c b/utils/statd/rmtcall.c index 7684b3b..35cbccb 100644 --- a/utils/statd/rmtcall.c +++ b/utils/statd/rmtcall.c @@ -46,6 +46,10 @@ #include "log.h" #include "ha-callout.h" +#if SIZEOF_SOCKLEN_T - 0 == 0 +#define socklen_t int +#endif + #define MAXMSGSIZE (2048 / sizeof(unsigned int)) static unsigned long xid = 0; /* RPC XID counter */ @@ -278,7 +282,7 @@ recv_rply(int sockfd, struct sockaddr_in *sin, u_long *portp) struct rpc_msg mesg; notify_list *lp = NULL; XDR xdr, *xdrs = &xdr; - int alen = sizeof(*sin); + socklen_t alen = sizeof(*sin); /* Receive message */ if ((msglen = recvfrom(sockfd, msgbuf, sizeof(msgbuf), 0, -- 2.39.5