Author: tuexen
Date: Tue Sep  4 22:45:00 2012
New Revision: 240115
URL: http://svn.freebsd.org/changeset/base/240115

Log:
  Use the consistenly the size of a variable. This helps to keep the code
  simpler for the userland implementation.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c      Tue Sep  4 22:40:49 2012        
(r240114)
+++ head/sys/netinet/sctp_output.c      Tue Sep  4 22:45:00 2012        
(r240115)
@@ -3371,7 +3371,7 @@ sctp_find_cmsg(int c_type, void *data, s
                        return (found);
                }
                m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh);
-               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) {
+               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) {
                        /* We dont't have a complete CMSG header. */
                        return (found);
                }
@@ -3386,11 +3386,11 @@ sctp_find_cmsg(int c_type, void *data, s
                    (cmh.cmsg_type == SCTP_PRINFO) ||
                    (cmh.cmsg_type == SCTP_AUTHINFO))))) {
                        if (c_type == cmh.cmsg_type) {
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < cpsize) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < cpsize) {
                                        return (found);
                                }
                                /* It is exactly what we want. Copy it out. */
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), cpsize, (caddr_t)data);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), cpsize, (caddr_t)data);
                                return (1);
                        } else {
                                struct sctp_sndrcvinfo *sndrcvinfo;
@@ -3404,10 +3404,10 @@ sctp_find_cmsg(int c_type, void *data, s
                                }
                                switch (cmh.cmsg_type) {
                                case SCTP_SNDINFO:
-                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_sndinfo)) {
+                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_sndinfo)) {
                                                return (found);
                                        }
-                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_sndinfo), 
(caddr_t)&sndinfo);
+                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_sndinfo), (caddr_t)&sndinfo);
                                        sndrcvinfo->sinfo_stream = 
sndinfo.snd_sid;
                                        sndrcvinfo->sinfo_flags = 
sndinfo.snd_flags;
                                        sndrcvinfo->sinfo_ppid = 
sndinfo.snd_ppid;
@@ -3415,18 +3415,18 @@ sctp_find_cmsg(int c_type, void *data, s
                                        sndrcvinfo->sinfo_assoc_id = 
sndinfo.snd_assoc_id;
                                        break;
                                case SCTP_PRINFO:
-                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_prinfo)) {
+                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_prinfo)) {
                                                return (found);
                                        }
-                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_prinfo), 
(caddr_t)&prinfo);
+                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_prinfo), (caddr_t)&prinfo);
                                        sndrcvinfo->sinfo_timetolive = 
prinfo.pr_value;
                                        sndrcvinfo->sinfo_flags |= 
prinfo.pr_policy;
                                        break;
                                case SCTP_AUTHINFO:
-                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_authinfo)) {
+                                       if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_authinfo)) {
                                                return (found);
                                        }
-                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_authinfo), 
(caddr_t)&authinfo);
+                                       m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_authinfo), (caddr_t)&authinfo);
                                        sndrcvinfo->sinfo_keynumber_valid = 1;
                                        sndrcvinfo->sinfo_keynumber = 
authinfo.auth_keynumber;
                                        break;
@@ -3466,7 +3466,7 @@ sctp_process_cmsgs_for_init(struct sctp_
                        return (1);
                }
                m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh);
-               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) {
+               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) {
                        /* We dont't have a complete CMSG header. */
                        *error = EINVAL;
                        return (1);
@@ -3479,11 +3479,11 @@ sctp_process_cmsgs_for_init(struct sctp_
                if (cmh.cmsg_level == IPPROTO_SCTP) {
                        switch (cmh.cmsg_type) {
                        case SCTP_INIT:
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct sctp_initmsg)) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct sctp_initmsg)) {
                                        *error = EINVAL;
                                        return (1);
                                }
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct sctp_initmsg), 
(caddr_t)&initmsg);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct sctp_initmsg), (caddr_t)&initmsg);
                                if (initmsg.sinit_max_attempts)
                                        stcb->asoc.max_init_times = 
initmsg.sinit_max_attempts;
                                if (initmsg.sinit_num_ostreams)
@@ -3523,7 +3523,7 @@ sctp_process_cmsgs_for_init(struct sctp_
                                break;
 #ifdef INET
                        case SCTP_DSTADDRV4:
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in_addr)) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) {
                                        *error = EINVAL;
                                        return (1);
                                }
@@ -3531,7 +3531,7 @@ sctp_process_cmsgs_for_init(struct sctp_
                                sin.sin_family = AF_INET;
                                sin.sin_len = sizeof(struct sockaddr_in);
                                sin.sin_port = stcb->rport;
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in_addr), 
(caddr_t)&sin.sin_addr);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
                                if ((sin.sin_addr.s_addr == INADDR_ANY) ||
                                    (sin.sin_addr.s_addr == INADDR_BROADCAST) ||
                                    IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
@@ -3547,7 +3547,7 @@ sctp_process_cmsgs_for_init(struct sctp_
 #endif
 #ifdef INET6
                        case SCTP_DSTADDRV6:
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in6_addr)) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) {
                                        *error = EINVAL;
                                        return (1);
                                }
@@ -3555,7 +3555,7 @@ sctp_process_cmsgs_for_init(struct sctp_
                                sin6.sin6_family = AF_INET6;
                                sin6.sin6_len = sizeof(struct sockaddr_in6);
                                sin6.sin6_port = stcb->rport;
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in6_addr), 
(caddr_t)&sin6.sin6_addr);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
                                if (IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr) ||
                                    IN6_IS_ADDR_MULTICAST(&sin6.sin6_addr)) {
                                        *error = EINVAL;
@@ -3623,7 +3623,7 @@ sctp_findassociation_cmsgs(struct sctp_i
                        return (NULL);
                }
                m_copydata(control, at, sizeof(cmh), (caddr_t)&cmh);
-               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(struct cmsghdr))) {
+               if (cmh.cmsg_len < CMSG_ALIGN(sizeof(cmh))) {
                        /* We dont't have a complete CMSG header. */
                        *error = EINVAL;
                        return (NULL);
@@ -3637,7 +3637,7 @@ sctp_findassociation_cmsgs(struct sctp_i
                        switch (cmh.cmsg_type) {
 #ifdef INET
                        case SCTP_DSTADDRV4:
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in_addr)) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in_addr)) {
                                        *error = EINVAL;
                                        return (NULL);
                                }
@@ -3645,13 +3645,13 @@ sctp_findassociation_cmsgs(struct sctp_i
                                sin.sin_family = AF_INET;
                                sin.sin_len = sizeof(struct sockaddr_in);
                                sin.sin_port = port;
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in_addr), 
(caddr_t)&sin.sin_addr);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
                                addr = (struct sockaddr *)&sin;
                                break;
 #endif
 #ifdef INET6
                        case SCTP_DSTADDRV6:
-                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(struct cmsghdr))) < sizeof(struct in6_addr)) {
+                               if ((size_t)(cmh.cmsg_len - 
CMSG_ALIGN(sizeof(cmh))) < sizeof(struct in6_addr)) {
                                        *error = EINVAL;
                                        return (NULL);
                                }
@@ -3659,7 +3659,7 @@ sctp_findassociation_cmsgs(struct sctp_i
                                sin6.sin6_family = AF_INET6;
                                sin6.sin6_len = sizeof(struct sockaddr_in6);
                                sin6.sin6_port = port;
-                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(struct cmsghdr)), sizeof(struct in6_addr), 
(caddr_t)&sin6.sin6_addr);
+                               m_copydata(control, at + 
CMSG_ALIGN(sizeof(cmh)), sizeof(struct in6_addr), (caddr_t)&sin6.sin6_addr);
 #ifdef INET
                                if (IN6_IS_ADDR_V4MAPPED(&sin6.sin6_addr)) {
                                        in6_sin6_2_sin(&sin, &sin6);
_______________________________________________
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