Author: pjd
Date: Thu Sep  5 00:17:38 2013
New Revision: 255221
URL: http://svnweb.freebsd.org/changeset/base/255221

Log:
  Style fixes. Most fixes are about not treating integers and pointers as
  booleans.

Modified:
  head/sys/kern/uipc_syscalls.c

Modified: head/sys/kern/uipc_syscalls.c
==============================================================================
--- head/sys/kern/uipc_syscalls.c       Thu Sep  5 00:11:59 2013        
(r255220)
+++ head/sys/kern/uipc_syscalls.c       Thu Sep  5 00:17:38 2013        
(r255221)
@@ -220,16 +220,16 @@ sys_socket(td, uap)
 #ifdef MAC
        error = mac_socket_check_create(td->td_ucred, uap->domain, type,
            uap->protocol);
-       if (error)
+       if (error != 0)
                return (error);
 #endif
        error = falloc(td, &fp, &fd, oflag);
-       if (error)
+       if (error != 0)
                return (error);
        /* An extra reference on `fp' has been held for us by falloc(). */
        error = socreate(uap->domain, &so, type, uap->protocol,
            td->td_ucred, td);
-       if (error) {
+       if (error != 0) {
                fdclose(td->td_proc->p_fd, fp, fd, td);
        } else {
                finit(fp, FREAD | FWRITE | fflag, DTYPE_SOCKET, so, &socketops);
@@ -274,7 +274,7 @@ kern_bindat(struct thread *td, int dirfd
        AUDIT_ARG_SOCKADDR(td, dirfd, sa);
        error = getsock_cap(td->td_proc->p_fd, fd,
            cap_rights_init(&rights, CAP_BIND), &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = fp->f_data;
 #ifdef KTRACE
@@ -374,7 +374,7 @@ accept1(td, s, uname, anamelen, flags)
                return (kern_accept4(td, s, NULL, NULL, flags, NULL));
 
        error = copyin(anamelen, &namelen, sizeof (namelen));
-       if (error)
+       if (error != 0)
                return (error);
 
        error = kern_accept4(td, s, &name, &namelen, flags, &fp);
@@ -383,7 +383,7 @@ accept1(td, s, uname, anamelen, flags)
         * return a namelen of zero for older code which might
         * ignore the return value from accept.
         */
-       if (error) {
+       if (error != 0) {
                (void) copyout(&namelen, anamelen, sizeof(*anamelen));
                return (error);
        }
@@ -399,7 +399,7 @@ accept1(td, s, uname, anamelen, flags)
        if (error == 0)
                error = copyout(&namelen, anamelen,
                    sizeof(namelen));
-       if (error)
+       if (error != 0)
                fdclose(td->td_proc->p_fd, fp, td->td_retval[0], td);
        fdrop(fp, td);
        free(name, M_SONAME);
@@ -420,22 +420,20 @@ kern_accept4(struct thread *td, int s, s
        struct filedesc *fdp;
        struct file *headfp, *nfp = NULL;
        struct sockaddr *sa = NULL;
-       int error;
        struct socket *head, *so;
-       int fd;
        cap_rights_t rights;
        u_int fflag;
        pid_t pgid;
-       int tmp;
+       int error, fd, tmp;
 
-       if (name)
+       if (name != NULL)
                *name = NULL;
 
        AUDIT_ARG_FD(s);
        fdp = td->td_proc->p_fd;
        error = getsock_cap(fdp, s, cap_rights_init(&rights, CAP_ACCEPT),
            &headfp, &fflag);
-       if (error)
+       if (error != 0)
                return (error);
        head = headfp->f_data;
        if ((head->so_options & SO_ACCEPTCONN) == 0) {
@@ -448,7 +446,7 @@ kern_accept4(struct thread *td, int s, s
                goto done;
 #endif
        error = falloc(td, &nfp, &fd, (flags & SOCK_CLOEXEC) ? O_CLOEXEC : 0);
-       if (error)
+       if (error != 0)
                goto done;
        ACCEPT_LOCK();
        if ((head->so_state & SS_NBIO) && TAILQ_EMPTY(&head->so_comp)) {
@@ -463,7 +461,7 @@ kern_accept4(struct thread *td, int s, s
                }
                error = msleep(&head->so_timeo, &accept_mtx, PSOCK | PCATCH,
                    "accept", 0);
-               if (error) {
+               if (error != 0) {
                        ACCEPT_UNLOCK();
                        goto noconnection;
                }
@@ -522,7 +520,7 @@ kern_accept4(struct thread *td, int s, s
        (void) fo_ioctl(nfp, FIOASYNC, &tmp, td->td_ucred, td);
        sa = 0;
        error = soaccept(so, &sa);
-       if (error) {
+       if (error != 0) {
                /*
                 * return a namelen of zero for older code which might
                 * ignore the return value from accept.
@@ -549,14 +547,13 @@ kern_accept4(struct thread *td, int s, s
                sa = NULL;
        }
 noconnection:
-       if (sa)
-               free(sa, M_SONAME);
+       free(sa, M_SONAME);
 
        /*
         * close the new descriptor, assuming someone hasn't ripped it
         * out from under us.
         */
-       if (error)
+       if (error != 0)
                fdclose(fdp, nfp, fd, td);
 
        /*
@@ -591,6 +588,7 @@ sys_accept4(td, uap)
        struct thread *td;
        struct accept4_args *uap;
 {
+
        if (uap->flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK))
                return (EINVAL);
 
@@ -636,14 +634,13 @@ kern_connectat(struct thread *td, int di
        struct socket *so;
        struct file *fp;
        cap_rights_t rights;
-       int error;
-       int interrupted = 0;
+       int error, interrupted = 0;
 
        AUDIT_ARG_FD(fd);
        AUDIT_ARG_SOCKADDR(td, dirfd, sa);
        error = getsock_cap(td->td_proc->p_fd, fd,
            cap_rights_init(&rights, CAP_CONNECT), &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = fp->f_data;
        if (so->so_state & SS_ISCONNECTING) {
@@ -656,14 +653,14 @@ kern_connectat(struct thread *td, int di
 #endif
 #ifdef MAC
        error = mac_socket_check_connect(td->td_ucred, so, sa);
-       if (error)
+       if (error != 0)
                goto bad;
 #endif
        if (dirfd == AT_FDCWD)
                error = soconnect(so, sa, td);
        else
                error = soconnectat(dirfd, so, sa, td);
-       if (error)
+       if (error != 0)
                goto bad;
        if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING)) {
                error = EINPROGRESS;
@@ -673,7 +670,7 @@ kern_connectat(struct thread *td, int di
        while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
                error = msleep(&so->so_timeo, SOCK_MTX(so), PSOCK | PCATCH,
                    "connec", 0);
-               if (error) {
+               if (error != 0) {
                        if (error == EINTR || error == ERESTART)
                                interrupted = 1;
                        break;
@@ -748,35 +745,35 @@ kern_socketpair(struct thread *td, int d
        /* We might want to have a separate check for socket pairs. */
        error = mac_socket_check_create(td->td_ucred, domain, type,
            protocol);
-       if (error)
+       if (error != 0)
                return (error);
 #endif
        error = socreate(domain, &so1, type, protocol, td->td_ucred, td);
-       if (error)
+       if (error != 0)
                return (error);
        error = socreate(domain, &so2, type, protocol, td->td_ucred, td);
-       if (error)
+       if (error != 0)
                goto free1;
        /* On success extra reference to `fp1' and 'fp2' is set by falloc. */
        error = falloc(td, &fp1, &fd, oflag);
-       if (error)
+       if (error != 0)
                goto free2;
        rsv[0] = fd;
        fp1->f_data = so1;      /* so1 already has ref count */
        error = falloc(td, &fp2, &fd, oflag);
-       if (error)
+       if (error != 0)
                goto free3;
        fp2->f_data = so2;      /* so2 already has ref count */
        rsv[1] = fd;
        error = soconnect2(so1, so2);
-       if (error)
+       if (error != 0)
                goto free4;
        if (type == SOCK_DGRAM) {
                /*
                 * Datagram socket connection is asymmetric.
                 */
                 error = soconnect2(so2, so1);
-                if (error)
+                if (error != 0)
                        goto free4;
        }
        finit(fp1, FREAD | FWRITE | fflag, DTYPE_SOCKET, fp1->f_data,
@@ -812,10 +809,10 @@ sys_socketpair(struct thread *td, struct
 
        error = kern_socketpair(td, uap->domain, uap->type,
            uap->protocol, sv);
-       if (error)
+       if (error != 0)
                return (error);
        error = copyout(sv, uap->rsv, 2 * sizeof(int));
-       if (error) {
+       if (error != 0) {
                (void)kern_close(td, sv[0]);
                (void)kern_close(td, sv[1]);
        }
@@ -840,7 +837,7 @@ sendit(td, s, mp, flags)
 
        if (mp->msg_name != NULL) {
                error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
-               if (error) {
+               if (error != 0) {
                        to = NULL;
                        goto bad;
                }
@@ -860,7 +857,7 @@ sendit(td, s, mp, flags)
                }
                error = sockargs(&control, mp->msg_control,
                    mp->msg_controllen, MT_CONTROL);
-               if (error)
+               if (error != 0)
                        goto bad;
 #ifdef COMPAT_OLDSOCK
                if (mp->msg_flags == MSG_COMPAT) {
@@ -880,8 +877,7 @@ sendit(td, s, mp, flags)
        error = kern_sendit(td, s, mp, flags, control, UIO_USERSPACE);
 
 bad:
-       if (to)
-               free(to, M_SONAME);
+       free(to, M_SONAME);
        return (error);
 }
 
@@ -898,12 +894,12 @@ kern_sendit(td, s, mp, flags, control, s
        struct uio auio;
        struct iovec *iov;
        struct socket *so;
-       int i, error;
-       ssize_t len;
        cap_rights_t rights;
 #ifdef KTRACE
        struct uio *ktruio = NULL;
 #endif
+       ssize_t len;
+       int i, error;
 
        AUDIT_ARG_FD(s);
        cap_rights_init(&rights, CAP_SEND);
@@ -912,7 +908,7 @@ kern_sendit(td, s, mp, flags, control, s
                cap_rights_set(&rights, CAP_CONNECT);
        }
        error = getsock_cap(td->td_proc->p_fd, s, &rights, &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = (struct socket *)fp->f_data;
 
@@ -924,11 +920,11 @@ kern_sendit(td, s, mp, flags, control, s
        if (mp->msg_name != NULL) {
                error = mac_socket_check_connect(td->td_ucred, so,
                    mp->msg_name);
-               if (error)
+               if (error != 0)
                        goto bad;
        }
        error = mac_socket_check_send(td->td_ucred, so);
-       if (error)
+       if (error != 0)
                goto bad;
 #endif
 
@@ -952,7 +948,7 @@ kern_sendit(td, s, mp, flags, control, s
 #endif
        len = auio.uio_resid;
        error = sosend(so, mp->msg_name, &auio, 0, control, flags, td);
-       if (error) {
+       if (error != 0) {
                if (auio.uio_resid != len && (error == ERESTART ||
                    error == EINTR || error == EWOULDBLOCK))
                        error = 0;
@@ -991,7 +987,6 @@ sys_sendto(td, uap)
 {
        struct msghdr msg;
        struct iovec aiov;
-       int error;
 
        msg.msg_name = uap->to;
        msg.msg_namelen = uap->tolen;
@@ -1003,8 +998,7 @@ sys_sendto(td, uap)
 #endif
        aiov.iov_base = uap->buf;
        aiov.iov_len = uap->len;
-       error = sendit(td, uap->s, &msg, uap->flags);
-       return (error);
+       return (sendit(td, uap->s, &msg, uap->flags));
 }
 
 #ifdef COMPAT_OLDSOCK
@@ -1020,7 +1014,6 @@ osend(td, uap)
 {
        struct msghdr msg;
        struct iovec aiov;
-       int error;
 
        msg.msg_name = 0;
        msg.msg_namelen = 0;
@@ -1030,8 +1023,7 @@ osend(td, uap)
        aiov.iov_len = uap->len;
        msg.msg_control = 0;
        msg.msg_flags = 0;
-       error = sendit(td, uap->s, &msg, uap->flags);
-       return (error);
+       return (sendit(td, uap->s, &msg, uap->flags));
 }
 
 int
@@ -1048,10 +1040,10 @@ osendmsg(td, uap)
        int error;
 
        error = copyin(uap->msg, &msg, sizeof (struct omsghdr));
-       if (error)
+       if (error != 0)
                return (error);
        error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                return (error);
        msg.msg_iov = iov;
        msg.msg_flags = MSG_COMPAT;
@@ -1075,10 +1067,10 @@ sys_sendmsg(td, uap)
        int error;
 
        error = copyin(uap->msg, &msg, sizeof (msg));
-       if (error)
+       if (error != 0)
                return (error);
        error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                return (error);
        msg.msg_iov = iov;
 #ifdef COMPAT_OLDSOCK
@@ -1099,9 +1091,6 @@ kern_recvit(td, s, mp, fromseg, controlp
 {
        struct uio auio;
        struct iovec *iov;
-       int i;
-       ssize_t len;
-       int error;
        struct mbuf *m, *control = NULL;
        caddr_t ctlbuf;
        struct file *fp;
@@ -1111,6 +1100,8 @@ kern_recvit(td, s, mp, fromseg, controlp
 #ifdef KTRACE
        struct uio *ktruio = NULL;
 #endif
+       ssize_t len;
+       int error, i;
 
        if (controlp != NULL)
                *controlp = NULL;
@@ -1118,13 +1109,13 @@ kern_recvit(td, s, mp, fromseg, controlp
        AUDIT_ARG_FD(s);
        error = getsock_cap(td->td_proc->p_fd, s,
            cap_rights_init(&rights, CAP_RECV), &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = fp->f_data;
 
 #ifdef MAC
        error = mac_socket_check_receive(td->td_ucred, so);
-       if (error) {
+       if (error != 0) {
                fdrop(fp, td);
                return (error);
        }
@@ -1152,7 +1143,7 @@ kern_recvit(td, s, mp, fromseg, controlp
        error = soreceive(so, &fromsa, &auio, NULL,
            (mp->msg_control || controlp) ? &control : NULL,
            &mp->msg_flags);
-       if (error) {
+       if (error != 0) {
                if (auio.uio_resid != len && (error == ERESTART ||
                    error == EINTR || error == EWOULDBLOCK))
                        error = 0;
@@ -1165,7 +1156,7 @@ kern_recvit(td, s, mp, fromseg, controlp
                ktrgenio(s, UIO_READ, ktruio, error);
        }
 #endif
-       if (error)
+       if (error != 0)
                goto out;
        td->td_retval[0] = len - auio.uio_resid;
        if (mp->msg_name) {
@@ -1183,7 +1174,7 @@ kern_recvit(td, s, mp, fromseg, controlp
                        if (fromseg == UIO_USERSPACE) {
                                error = copyout(fromsa, mp->msg_name,
                                    (unsigned)len);
-                               if (error)
+                               if (error != 0)
                                        goto out;
                        } else
                                bcopy(fromsa, mp->msg_name, len);
@@ -1242,8 +1233,7 @@ out:
        if (fromsa && KTRPOINT(td, KTR_STRUCT))
                ktrsockaddr(fromsa);
 #endif
-       if (fromsa)
-               free(fromsa, M_SONAME);
+       free(fromsa, M_SONAME);
 
        if (error == 0 && controlp != NULL)
                *controlp = control;
@@ -1263,9 +1253,9 @@ recvit(td, s, mp, namelenp)
        int error;
 
        error = kern_recvit(td, s, mp, UIO_USERSPACE, NULL);
-       if (error)
+       if (error != 0)
                return (error);
-       if (namelenp) {
+       if (namelenp != NULL) {
                error = copyout(&mp->msg_namelen, namelenp, sizeof (socklen_t));
 #ifdef COMPAT_OLDSOCK
                if (mp->msg_flags & MSG_COMPAT)
@@ -1294,7 +1284,7 @@ sys_recvfrom(td, uap)
        if (uap->fromlenaddr) {
                error = copyin(uap->fromlenaddr,
                    &msg.msg_namelen, sizeof (msg.msg_namelen));
-               if (error)
+               if (error != 0)
                        goto done2;
        } else {
                msg.msg_namelen = 0;
@@ -1308,7 +1298,7 @@ sys_recvfrom(td, uap)
        msg.msg_flags = uap->flags;
        error = recvit(td, uap->s, &msg, uap->fromlenaddr);
 done2:
-       return(error);
+       return (error);
 }
 
 #ifdef COMPAT_OLDSOCK
@@ -1336,7 +1326,6 @@ orecv(td, uap)
 {
        struct msghdr msg;
        struct iovec aiov;
-       int error;
 
        msg.msg_name = 0;
        msg.msg_namelen = 0;
@@ -1346,8 +1335,7 @@ orecv(td, uap)
        aiov.iov_len = uap->len;
        msg.msg_control = 0;
        msg.msg_flags = uap->flags;
-       error = recvit(td, uap->s, &msg, NULL);
-       return (error);
+       return (recvit(td, uap->s, &msg, NULL));
 }
 
 /*
@@ -1369,10 +1357,10 @@ orecvmsg(td, uap)
        int error;
 
        error = copyin(uap->msg, &msg, sizeof (struct omsghdr));
-       if (error)
+       if (error != 0)
                return (error);
        error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                return (error);
        msg.msg_flags = uap->flags | MSG_COMPAT;
        msg.msg_iov = iov;
@@ -1399,10 +1387,10 @@ sys_recvmsg(td, uap)
        int error;
 
        error = copyin(uap->msg, &msg, sizeof (msg));
-       if (error)
+       if (error != 0)
                return (error);
        error = copyiniov(msg.msg_iov, msg.msg_iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                return (error);
        msg.msg_flags = uap->flags;
 #ifdef COMPAT_OLDSOCK
@@ -1471,11 +1459,11 @@ kern_setsockopt(td, s, level, name, val,
        enum uio_seg valseg;
        socklen_t valsize;
 {
-       int error;
        struct socket *so;
        struct file *fp;
        struct sockopt sopt;
        cap_rights_t rights;
+       int error;
 
        if (val == NULL && valsize != 0)
                return (EFAULT);
@@ -1522,11 +1510,11 @@ sys_getsockopt(td, uap)
        } */ *uap;
 {
        socklen_t valsize;
-       int     error;
+       int error;
 
        if (uap->val) {
                error = copyin(uap->avalsize, &valsize, sizeof (valsize));
-               if (error)
+               if (error != 0)
                        return (error);
        }
 
@@ -1552,11 +1540,11 @@ kern_getsockopt(td, s, level, name, val,
        enum uio_seg valseg;
        socklen_t *valsize;
 {
-       int error;
-       struct  socket *so;
+       struct socket *so;
        struct file *fp;
-       struct  sockopt sopt;
+       struct sockopt sopt;
        cap_rights_t rights;
+       int error;
 
        if (val == NULL)
                *valsize = 0;
@@ -1610,11 +1598,11 @@ getsockname1(td, uap, compat)
        int error;
 
        error = copyin(uap->alen, &len, sizeof(len));
-       if (error)
+       if (error != 0)
                return (error);
 
        error = kern_getsockname(td, uap->fdes, &sa, &len);
-       if (error)
+       if (error != 0)
                return (error);
 
        if (len != 0) {
@@ -1643,14 +1631,14 @@ kern_getsockname(struct thread *td, int 
        AUDIT_ARG_FD(fd);
        error = getsock_cap(td->td_proc->p_fd, fd,
            cap_rights_init(&rights, CAP_GETSOCKNAME), &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = fp->f_data;
        *sa = NULL;
        CURVNET_SET(so->so_vnet);
        error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, sa);
        CURVNET_RESTORE();
-       if (error)
+       if (error != 0)
                goto bad;
        if (*sa == NULL)
                len = 0;
@@ -1663,7 +1651,7 @@ kern_getsockname(struct thread *td, int 
 #endif
 bad:
        fdrop(fp, td);
-       if (error && *sa) {
+       if (error != 0 && *sa != NULL) {
                free(*sa, M_SONAME);
                *sa = NULL;
        }
@@ -1709,11 +1697,11 @@ getpeername1(td, uap, compat)
        int error;
 
        error = copyin(uap->alen, &len, sizeof (len));
-       if (error)
+       if (error != 0)
                return (error);
 
        error = kern_getpeername(td, uap->fdes, &sa, &len);
-       if (error)
+       if (error != 0)
                return (error);
 
        if (len != 0) {
@@ -1742,7 +1730,7 @@ kern_getpeername(struct thread *td, int 
        AUDIT_ARG_FD(fd);
        error = getsock_cap(td->td_proc->p_fd, fd,
            cap_rights_init(&rights, CAP_GETPEERNAME), &fp, NULL);
-       if (error)
+       if (error != 0)
                return (error);
        so = fp->f_data;
        if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) {
@@ -1753,7 +1741,7 @@ kern_getpeername(struct thread *td, int 
        CURVNET_SET(so->so_vnet);
        error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, sa);
        CURVNET_RESTORE();
-       if (error)
+       if (error != 0)
                goto bad;
        if (*sa == NULL)
                len = 0;
@@ -1765,7 +1753,7 @@ kern_getpeername(struct thread *td, int 
                ktrsockaddr(*sa);
 #endif
 bad:
-       if (error && *sa) {
+       if (error != 0 && *sa != NULL) {
                free(*sa, M_SONAME);
                *sa = NULL;
        }
@@ -1817,7 +1805,7 @@ sockargs(mp, buf, buflen, type)
        m = m_get2(buflen, M_WAITOK, type, 0);
        m->m_len = buflen;
        error = copyin(buf, mtod(m, caddr_t), (u_int)buflen);
-       if (error)
+       if (error != 0)
                (void) m_free(m);
        else {
                *mp = m;
@@ -1849,7 +1837,7 @@ getsockaddr(namp, uaddr, len)
                return (EINVAL);
        sa = malloc(len, M_SONAME, M_WAITOK);
        error = copyin(uaddr, sa, len);
-       if (error) {
+       if (error != 0) {
                free(sa, M_SONAME);
        } else {
 #if defined(COMPAT_OLDSOCK) && BYTE_ORDER != BIG_ENDIAN
@@ -1936,16 +1924,16 @@ do_sendfile(struct thread *td, struct se
 
        if (uap->hdtr != NULL) {
                error = copyin(uap->hdtr, &hdtr, sizeof(hdtr));
-               if (error)
+               if (error != 0)
                        goto out;
                if (hdtr.headers != NULL) {
                        error = copyinuio(hdtr.headers, hdtr.hdr_cnt, &hdr_uio);
-                       if (error)
+                       if (error != 0)
                                goto out;
                }
                if (hdtr.trailers != NULL) {
                        error = copyinuio(hdtr.trailers, hdtr.trl_cnt, 
&trl_uio);
-                       if (error)
+                       if (error != 0)
                                goto out;
 
                }
@@ -1967,10 +1955,8 @@ do_sendfile(struct thread *td, struct se
        fdrop(fp, td);
 
 out:
-       if (hdr_uio)
-               free(hdr_uio, M_IOV);
-       if (trl_uio)
-               free(trl_uio, M_IOV);
+       free(hdr_uio, M_IOV);
+       free(trl_uio, M_IOV);
        return (error);
 }
 
@@ -2005,11 +1991,10 @@ vn_sendfile(struct file *fp, int sockfd,
        struct sf_buf *sf;
        struct vm_page *pg;
        struct vattr va;
+       struct sendfile_sync *sfs = NULL;
        cap_rights_t rights;
        off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0;
-       int error, hdrlen = 0, mnw = 0;
-       int bsize;
-       struct sendfile_sync *sfs = NULL;
+       int bsize, error, hdrlen = 0, mnw = 0;
 
        vn_lock(vp, LK_SHARED | LK_RETRY);
        if (vp->v_type == VREG) {
@@ -2082,7 +2067,7 @@ vn_sendfile(struct file *fp, int sockfd,
 
 #ifdef MAC
        error = mac_socket_check_send(td->td_ucred, so);
-       if (error)
+       if (error != 0)
                goto out;
 #endif
 
@@ -2197,7 +2182,7 @@ retry_space:
                         * been interrupted by a signal. If we've sent anything
                         * then return bytes sent, otherwise return the error.
                         */
-                       if (error) {
+                       if (error != 0) {
                                SOCKBUF_UNLOCK(&so->so_snd);
                                goto done;
                        }
@@ -2289,10 +2274,10 @@ retry_space:
                                    IO_VMIO | ((readahead / bsize) << 
IO_SEQSHIFT),
                                    td->td_ucred, NOCRED, &resid, td);
                                SFSTAT_INC(sf_iocnt);
-                               if (error)
+                               if (error != 0)
                                        VM_OBJECT_WLOCK(obj);
                        }
-                       if (error) {
+                       if (error != 0) {
                                vm_page_lock(pg);
                                vm_page_unwire(pg, 0);
                                /*
@@ -2417,7 +2402,7 @@ retry_space:
                /* Quit outer loop on error or when we're done. */
                if (done)
                        break;
-               if (error)
+               if (error != 0)
                        goto done;
        }
 
@@ -2484,23 +2469,22 @@ sys_sctp_peeloff(td, uap)
 {
 #if (defined(INET) || defined(INET6)) && defined(SCTP)
        struct file *nfp = NULL;
-       int error;
        struct socket *head, *so;
-       int fd;
        cap_rights_t rights;
        u_int fflag;
+       int error, fd;
 
        AUDIT_ARG_FD(uap->sd);
        error = fgetsock(td, uap->sd, cap_rights_init(&rights, CAP_PEELOFF),
            &head, &fflag);
-       if (error)
+       if (error != 0)
                goto done2;
        if (head->so_proto->pr_protocol != IPPROTO_SCTP) {
                error = EOPNOTSUPP;
                goto done;
        }
        error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name);
-       if (error)
+       if (error != 0)
                goto done;
        /*
         * At this point we know we do have a assoc to pull
@@ -2509,7 +2493,7 @@ sys_sctp_peeloff(td, uap)
         */
 
        error = falloc(td, &nfp, &fd, 0);
-       if (error)
+       if (error != 0)
                goto done;
        td->td_retval[0] = fd;
 
@@ -2539,7 +2523,7 @@ sys_sctp_peeloff(td, uap)
        ACCEPT_UNLOCK();
        finit(nfp, fflag, DTYPE_SOCKET, so, &socketops);
        error = sctp_do_peeloff(head, so, (sctp_assoc_t)uap->name);
-       if (error)
+       if (error != 0)
                goto noconnection;
        if (head->so_sigio != NULL)
                fsetown(fgetown(&head->so_sigio), &so->so_sigio);
@@ -2549,7 +2533,7 @@ noconnection:
         * close the new descriptor, assuming someone hasn't ripped it
         * out from under us.
         */
-       if (error)
+       if (error != 0)
                fdclose(td->td_proc->p_fd, nfp, fd, td);
 
        /*
@@ -2584,7 +2568,6 @@ sys_sctp_generic_sendmsg (td, uap)
        struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
        struct socket *so;
        struct file *fp = NULL;
-       int error = 0, len;
        struct sockaddr *to = NULL;
 #ifdef KTRACE
        struct uio *ktruio = NULL;
@@ -2592,18 +2575,19 @@ sys_sctp_generic_sendmsg (td, uap)
        struct uio auio;
        struct iovec iov[1];
        cap_rights_t rights;
+       int error = 0, len;
 
-       if (uap->sinfo) {
+       if (uap->sinfo != NULL) {
                error = copyin(uap->sinfo, &sinfo, sizeof (sinfo));
-               if (error)
+               if (error != 0)
                        return (error);
                u_sinfo = &sinfo;
        }
 
        cap_rights_init(&rights, CAP_SEND);
-       if (uap->tolen) {
+       if (uap->tolen != 0) {
                error = getsockaddr(&to, uap->to, uap->tolen);
-               if (error) {
+               if (error != 0) {
                        to = NULL;
                        goto sctp_bad2;
                }
@@ -2612,7 +2596,7 @@ sys_sctp_generic_sendmsg (td, uap)
 
        AUDIT_ARG_FD(uap->sd);
        error = getsock_cap(td->td_proc->p_fd, uap->sd, &rights, &fp, NULL);
-       if (error)
+       if (error != 0)
                goto sctp_bad;
 #ifdef KTRACE
        if (to && (KTRPOINT(td, KTR_STRUCT)))
@@ -2629,7 +2613,7 @@ sys_sctp_generic_sendmsg (td, uap)
        }
 #ifdef MAC
        error = mac_socket_check_send(td->td_ucred, so);
-       if (error)
+       if (error != 0)
                goto sctp_bad;
 #endif /* MAC */
 
@@ -2642,11 +2626,10 @@ sys_sctp_generic_sendmsg (td, uap)
        auio.uio_resid = 0;
        len = auio.uio_resid = uap->mlen;
        CURVNET_SET(so->so_vnet);
-       error = sctp_lower_sosend(so, to, &auio,
-                   (struct mbuf *)NULL, (struct mbuf *)NULL,
-                   uap->flags, u_sinfo, td);
+       error = sctp_lower_sosend(so, to, &auio, (struct mbuf *)NULL,
+           (struct mbuf *)NULL, uap->flags, u_sinfo, td);
        CURVNET_RESTORE();
-       if (error) {
+       if (error != 0) {
                if (auio.uio_resid != len && (error == ERESTART ||
                    error == EINTR || error == EWOULDBLOCK))
                        error = 0;
@@ -2667,11 +2650,10 @@ sys_sctp_generic_sendmsg (td, uap)
        }
 #endif /* KTRACE */
 sctp_bad:
-       if (fp)
+       if (fp != NULL)
                fdrop(fp, td);
 sctp_bad2:
-       if (to)
-               free(to, M_SONAME);
+       free(to, M_SONAME);
        return (error);
 #else  /* SCTP */
        return (EOPNOTSUPP);
@@ -2695,8 +2677,6 @@ sys_sctp_generic_sendmsg_iov(td, uap)
        struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL;
        struct socket *so;
        struct file *fp = NULL;
-       int error=0, i;
-       ssize_t len;
        struct sockaddr *to = NULL;
 #ifdef KTRACE
        struct uio *ktruio = NULL;
@@ -2704,17 +2684,19 @@ sys_sctp_generic_sendmsg_iov(td, uap)
        struct uio auio;
        struct iovec *iov, *tiov;
        cap_rights_t rights;
+       ssize_t len;
+       int error, i;
 
-       if (uap->sinfo) {
+       if (uap->sinfo != NULL) {
                error = copyin(uap->sinfo, &sinfo, sizeof (sinfo));
-               if (error)
+               if (error != 0)
                        return (error);
                u_sinfo = &sinfo;
        }
        cap_rights_init(&rights, CAP_SEND);
-       if (uap->tolen) {
+       if (uap->tolen != 0) {
                error = getsockaddr(&to, uap->to, uap->tolen);
-               if (error) {
+               if (error != 0) {
                        to = NULL;
                        goto sctp_bad2;
                }
@@ -2723,7 +2705,7 @@ sys_sctp_generic_sendmsg_iov(td, uap)
 
        AUDIT_ARG_FD(uap->sd);
        error = getsock_cap(td->td_proc->p_fd, uap->sd, &rights, &fp, NULL);
-       if (error)
+       if (error != 0)
                goto sctp_bad1;
 
 #ifdef COMPAT_FREEBSD32
@@ -2733,7 +2715,7 @@ sys_sctp_generic_sendmsg_iov(td, uap)
        else
 #endif
                error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                goto sctp_bad1;
 #ifdef KTRACE
        if (to && (KTRPOINT(td, KTR_STRUCT)))
@@ -2747,7 +2729,7 @@ sys_sctp_generic_sendmsg_iov(td, uap)
        }
 #ifdef MAC
        error = mac_socket_check_send(td->td_ucred, so);
-       if (error)
+       if (error != 0)
                goto sctp_bad;
 #endif /* MAC */
 
@@ -2771,7 +2753,7 @@ sys_sctp_generic_sendmsg_iov(td, uap)
                    (struct mbuf *)NULL, (struct mbuf *)NULL,
                    uap->flags, u_sinfo, td);
        CURVNET_RESTORE();
-       if (error) {
+       if (error != 0) {
                if (auio.uio_resid != len && (error == ERESTART ||
                    error == EINTR || error == EWOULDBLOCK))
                        error = 0;
@@ -2794,11 +2776,10 @@ sys_sctp_generic_sendmsg_iov(td, uap)
 sctp_bad:
        free(iov, M_IOV);
 sctp_bad1:
-       if (fp)
+       if (fp != NULL)
                fdrop(fp, td);
 sctp_bad2:
-       if (to)
-               free(to, M_SONAME);
+       free(to, M_SONAME);
        return (error);
 #else  /* SCTP */
        return (EOPNOTSUPP);
@@ -2826,21 +2807,18 @@ sys_sctp_generic_recvmsg(td, uap)
        struct socket *so;
        struct file *fp = NULL;
        struct sockaddr *fromsa;
-       int fromlen;
-       ssize_t len;
-       int i, msg_flags;
-       int error = 0;
        cap_rights_t rights;
 #ifdef KTRACE
        struct uio *ktruio = NULL;
 #endif
+       ssize_t len;
+       int error, fromlen, i, msg_flags;
 
        AUDIT_ARG_FD(uap->sd);
        error = getsock_cap(td->td_proc->p_fd, uap->sd,
            cap_rights_init(&rights, CAP_RECV), &fp, NULL);
-       if (error) {
+       if (error != 0)
                return (error);
-       }
 #ifdef COMPAT_FREEBSD32
        if (SV_CURPROC_FLAG(SV_ILP32))
                error = freebsd32_copyiniov((struct iovec32 *)uap->iov,
@@ -2848,7 +2826,7 @@ sys_sctp_generic_recvmsg(td, uap)
        else
 #endif
                error = copyiniov(uap->iov, uap->iovlen, &iov, EMSGSIZE);
-       if (error)
+       if (error != 0)
                goto out1;
 
        so = fp->f_data;
@@ -2858,25 +2836,21 @@ sys_sctp_generic_recvmsg(td, uap)
        }
 #ifdef MAC
        error = mac_socket_check_receive(td->td_ucred, so);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to