Date: Sat, 11 Feb 2012 00:51:26 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r231489 - in stable/8/lib: . libc/net liblzma librtld_db libusb Message-ID: <201202110051.q1B0pQnA005148@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Sat Feb 11 00:51:26 2012 New Revision: 231489 URL: http://svn.freebsd.org/changeset/base/231489 Log: MFC r228630: Address warnings found by clang. Modified: stable/8/lib/libc/net/sctp_sys_calls.c Directory Properties: stable/8/lib/ (props changed) stable/8/lib/Makefile (props changed) stable/8/lib/Makefile.inc (props changed) stable/8/lib/bind/ (props changed) stable/8/lib/csu/ (props changed) stable/8/lib/libalias/ (props changed) stable/8/lib/libarchive/ (props changed) stable/8/lib/libauditd/ (props changed) stable/8/lib/libautofs/ (props changed) stable/8/lib/libbegemot/ (props changed) stable/8/lib/libbluetooth/ (props changed) stable/8/lib/libbsm/ (props changed) stable/8/lib/libbsnmp/ (props changed) stable/8/lib/libbz2/ (props changed) stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) stable/8/lib/libc_r/ (props changed) stable/8/lib/libcalendar/ (props changed) stable/8/lib/libcam/ (props changed) stable/8/lib/libcom_err/ (props changed) stable/8/lib/libcompat/ (props changed) stable/8/lib/libcrypt/ (props changed) stable/8/lib/libdevinfo/ (props changed) stable/8/lib/libdevstat/ (props changed) stable/8/lib/libdisk/ (props changed) stable/8/lib/libdwarf/ (props changed) stable/8/lib/libedit/ (props changed) stable/8/lib/libelf/ (props changed) stable/8/lib/libexpat/ (props changed) stable/8/lib/libfetch/ (props changed) stable/8/lib/libftpio/ (props changed) stable/8/lib/libgeom/ (props changed) stable/8/lib/libgpib/ (props changed) stable/8/lib/libgssapi/ (props changed) stable/8/lib/libipsec/ (props changed) stable/8/lib/libipx/ (props changed) stable/8/lib/libjail/ (props changed) stable/8/lib/libkiconv/ (props changed) stable/8/lib/libkse/ (props changed) stable/8/lib/libkvm/ (props changed) stable/8/lib/liblzma/ (props changed) stable/8/lib/liblzma/Makefile (props changed) stable/8/lib/liblzma/Symbol.map (props changed) stable/8/lib/liblzma/Versions.def (props changed) stable/8/lib/liblzma/config.h (props changed) stable/8/lib/libmagic/ (props changed) stable/8/lib/libmd/ (props changed) stable/8/lib/libmemstat/ (props changed) stable/8/lib/libmilter/ (props changed) stable/8/lib/libmp/ (props changed) stable/8/lib/libncp/ (props changed) stable/8/lib/libnetgraph/ (props changed) stable/8/lib/libngatm/ (props changed) stable/8/lib/libopie/ (props changed) stable/8/lib/libpam/ (props changed) stable/8/lib/libpcap/ (props changed) stable/8/lib/libpmc/ (props changed) stable/8/lib/libproc/ (props changed) stable/8/lib/libradius/ (props changed) stable/8/lib/librpcsec_gss/ (props changed) stable/8/lib/librpcsvc/ (props changed) stable/8/lib/librt/ (props changed) stable/8/lib/librtld_db/ (props changed) stable/8/lib/librtld_db/Makefile (props changed) stable/8/lib/librtld_db/librtld_db.3 (props changed) stable/8/lib/librtld_db/rtld_db.c (props changed) stable/8/lib/librtld_db/rtld_db.h (props changed) stable/8/lib/libsbuf/ (props changed) stable/8/lib/libsdp/ (props changed) stable/8/lib/libsm/ (props changed) stable/8/lib/libsmb/ (props changed) stable/8/lib/libsmdb/ (props changed) stable/8/lib/libsmutil/ (props changed) stable/8/lib/libstand/ (props changed) stable/8/lib/libtacplus/ (props changed) stable/8/lib/libtelnet/ (props changed) stable/8/lib/libthr/ (props changed) stable/8/lib/libthread_db/ (props changed) stable/8/lib/libufs/ (props changed) stable/8/lib/libugidfw/ (props changed) stable/8/lib/libusb/ (props changed) stable/8/lib/libusb/usb.h (props changed) stable/8/lib/libusbhid/ (props changed) stable/8/lib/libutil/ (props changed) stable/8/lib/libvgl/ (props changed) stable/8/lib/libwrap/ (props changed) stable/8/lib/liby/ (props changed) stable/8/lib/libypclnt/ (props changed) stable/8/lib/libz/ (props changed) stable/8/lib/libz/contrib/ (props changed) stable/8/lib/msun/ (props changed) stable/8/lib/ncurses/ (props changed) Modified: stable/8/lib/libc/net/sctp_sys_calls.c ============================================================================== --- stable/8/lib/libc/net/sctp_sys_calls.c Sat Feb 11 00:49:54 2012 (r231488) +++ stable/8/lib/libc/net/sctp_sys_calls.c Sat Feb 11 00:51:26 2012 (r231489) @@ -245,7 +245,8 @@ sctp_bindx(int sd, struct sockaddr *addr struct sockaddr *sa; struct sockaddr_in *sin; struct sockaddr_in6 *sin6; - int i, sz, argsz; + int i; + size_t argsz; uint16_t sport = 0; /* validate the flags */ @@ -269,7 +270,6 @@ sctp_bindx(int sd, struct sockaddr *addr /* First pre-screen the addresses */ sa = addrs; for (i = 0; i < addrcnt; i++) { - sz = sa->sa_len; if (sa->sa_family == AF_INET) { if (sa->sa_len != sizeof(struct sockaddr_in)) goto out_error; @@ -307,7 +307,7 @@ sctp_bindx(int sd, struct sockaddr *addr goto out_error; } - sa = (struct sockaddr *)((caddr_t)sa + sz); + sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); } sa = addrs; /* @@ -319,7 +319,6 @@ sctp_bindx(int sd, struct sockaddr *addr sin->sin_port = sport; } for (i = 0; i < addrcnt; i++) { - sz = sa->sa_len; if (sa->sa_family == AF_INET) { if (sa->sa_len != sizeof(struct sockaddr_in)) goto out_error; @@ -335,13 +334,13 @@ sctp_bindx(int sd, struct sockaddr *addr } memset(gaddrs, 0, argsz); gaddrs->sget_assoc_id = 0; - memcpy(gaddrs->addr, sa, sz); + memcpy(gaddrs->addr, sa, sa->sa_len); if (setsockopt(sd, IPPROTO_SCTP, flags, gaddrs, (socklen_t) argsz) != 0) { free(gaddrs); return (-1); } - sa = (struct sockaddr *)((caddr_t)sa + sz); + sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); } free(gaddrs); return (0); @@ -427,10 +426,9 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, { struct sctp_getaddresses *addrs; struct sockaddr *sa; - struct sockaddr *re; sctp_assoc_t asoc; caddr_t lim; - socklen_t siz; + socklen_t opt_len; int cnt; if (raddrs == NULL) { @@ -438,30 +436,28 @@ sctp_getpaddrs(int sd, sctp_assoc_t id, return (-1); } asoc = id; - siz = sizeof(sctp_assoc_t); + opt_len = (socklen_t) sizeof(sctp_assoc_t); if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_REMOTE_ADDR_SIZE, - &asoc, &siz) != 0) { + &asoc, &opt_len) != 0) { return (-1); } /* size required is returned in 'asoc' */ - siz = (size_t)asoc; - siz += sizeof(struct sctp_getaddresses); - addrs = calloc(1, siz); + opt_len = (socklen_t) ((size_t)asoc + sizeof(struct sctp_getaddresses)); + addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { return (-1); } addrs->sget_assoc_id = id; /* Now lets get the array of addresses */ if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_PEER_ADDRESSES, - addrs, &siz) != 0) { + addrs, &opt_len) != 0) { free(addrs); return (-1); } - re = (struct sockaddr *)&addrs->addr[0]; - *raddrs = re; + *raddrs = (struct sockaddr *)&addrs->addr[0]; cnt = 0; sa = (struct sockaddr *)&addrs->addr[0]; - lim = (caddr_t)addrs + siz; + lim = (caddr_t)addrs + opt_len; while (((caddr_t)sa < lim) && (sa->sa_len > 0)) { sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); cnt++; @@ -484,11 +480,10 @@ int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **raddrs) { struct sctp_getaddresses *addrs; - struct sockaddr *re; caddr_t lim; struct sockaddr *sa; - int size_of_addresses; - socklen_t siz; + size_t size_of_addresses; + socklen_t opt_len; int cnt; if (raddrs == NULL) { @@ -496,9 +491,9 @@ sctp_getladdrs(int sd, sctp_assoc_t id, return (-1); } size_of_addresses = 0; - siz = sizeof(int); + opt_len = (socklen_t) sizeof(int); if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE, - &size_of_addresses, &siz) != 0) { + &size_of_addresses, &opt_len) != 0) { errno = ENOMEM; return (-1); } @@ -506,9 +501,10 @@ sctp_getladdrs(int sd, sctp_assoc_t id, errno = ENOTCONN; return (-1); } - siz = size_of_addresses + sizeof(struct sockaddr_storage); - siz += sizeof(struct sctp_getaddresses); - addrs = calloc(1, siz); + opt_len = (socklen_t) (size_of_addresses + + sizeof(struct sockaddr_storage) + + sizeof(struct sctp_getaddresses)); + addrs = calloc(1, (size_t)opt_len); if (addrs == NULL) { errno = ENOMEM; return (-1); @@ -516,16 +512,15 @@ sctp_getladdrs(int sd, sctp_assoc_t id, addrs->sget_assoc_id = id; /* Now lets get the array of addresses */ if (getsockopt(sd, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDRESSES, addrs, - &siz) != 0) { + &opt_len) != 0) { free(addrs); errno = ENOMEM; return (-1); } - re = (struct sockaddr *)&addrs->addr[0]; - *raddrs = re; + *raddrs = (struct sockaddr *)&addrs->addr[0]; cnt = 0; sa = (struct sockaddr *)&addrs->addr[0]; - lim = (caddr_t)addrs + siz; + lim = (caddr_t)addrs + opt_len; while (((caddr_t)sa < lim) && (sa->sa_len > 0)) { sa = (struct sockaddr *)((caddr_t)sa + sa->sa_len); cnt++; @@ -732,7 +727,8 @@ sctp_sendx(int sd, const void *msg, size ssize_t ret; int i, cnt, *aa, saved_errno; char *buf; - int add_len, len, no_end_cx = 0; + int no_end_cx = 0; + size_t len, add_len; struct sockaddr *at; if (addrs == NULL) { @@ -782,7 +778,7 @@ sctp_sendx(int sd, const void *msg, size aa = (int *)buf; *aa = cnt; aa++; - memcpy((caddr_t)aa, addrs, (len - sizeof(int))); + memcpy((caddr_t)aa, addrs, (size_t)(len - sizeof(int))); ret = setsockopt(sd, IPPROTO_SCTP, SCTP_CONNECT_X_DELAYED, (void *)buf, (socklen_t) len); @@ -859,7 +855,6 @@ sctp_recvmsg(int s, #else struct sctp_sndrcvinfo *s_info; ssize_t sz; - int sinfo_found = 0; struct msghdr msg; struct iovec iov; char controlVector[SCTP_CONTROL_VEC_SIZE_RCV]; @@ -888,7 +883,6 @@ sctp_recvmsg(int s, return (sz); } s_info = NULL; - len = sz; if (sinfo) { sinfo->sinfo_assoc_id = 0; } @@ -909,7 +903,6 @@ sctp_recvmsg(int s, /* Copy it to the user */ if (sinfo) *sinfo = *s_info; - sinfo_found = 1; break; } else if (cmsg->cmsg_type == SCTP_EXTRCV) { /* @@ -922,7 +915,6 @@ sctp_recvmsg(int s, if (sinfo) { memcpy(sinfo, s_info, sizeof(struct sctp_extrcvinfo)); } - sinfo_found = 1; break; } @@ -1055,7 +1047,7 @@ sctp_sendv(int sd, cmsgbuf = malloc(CMSG_SPACE(sizeof(struct sctp_sndinfo)) + CMSG_SPACE(sizeof(struct sctp_prinfo)) + CMSG_SPACE(sizeof(struct sctp_authinfo)) + - addrcnt * CMSG_SPACE(sizeof(struct in6_addr))); + (size_t)addrcnt * CMSG_SPACE(sizeof(struct in6_addr))); if (cmsgbuf == NULL) { errno = ENOBUFS; return (-1);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202110051.q1B0pQnA005148>