aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorRobert P. J. Day <rpjday@crashcourse.ca>2008-04-12 21:54:24 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-12 21:54:24 -0400
commit9dbc15f055f05393ace4f1733f160ec3d188cf9b (patch)
treec3aca36fdb57d7b64aa5d5fdea0b7cf048c88dc7 /net/sctp/socket.c
parent30e935600776b45db38238355f0de2b8f72b3847 (diff)
[SCTP]: "list_for_each()" -> "list_for_each_entry()" where appropriate.
Replacing (almost) all invocations of list_for_each() with list_for_each_entry() tightens up the code and allows for the deletion of numerous list iterator variables that are no longer necessary. Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c56
1 files changed, 17 insertions, 39 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 025f467d80dd..8c90289ba400 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -513,7 +513,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
513 union sctp_addr saveaddr; 513 union sctp_addr saveaddr;
514 void *addr_buf; 514 void *addr_buf;
515 struct sctp_af *af; 515 struct sctp_af *af;
516 struct list_head *pos;
517 struct list_head *p; 516 struct list_head *p;
518 int i; 517 int i;
519 int retval = 0; 518 int retval = 0;
@@ -527,8 +526,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
527 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n", 526 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
528 __func__, sk, addrs, addrcnt); 527 __func__, sk, addrs, addrcnt);
529 528
530 list_for_each(pos, &ep->asocs) { 529 list_for_each_entry(asoc, &ep->asocs, asocs) {
531 asoc = list_entry(pos, struct sctp_association, asocs);
532 530
533 if (!asoc->peer.asconf_capable) 531 if (!asoc->peer.asconf_capable)
534 continue; 532 continue;
@@ -699,7 +697,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
699 union sctp_addr *laddr; 697 union sctp_addr *laddr;
700 void *addr_buf; 698 void *addr_buf;
701 struct sctp_af *af; 699 struct sctp_af *af;
702 struct list_head *pos, *pos1;
703 struct sctp_sockaddr_entry *saddr; 700 struct sctp_sockaddr_entry *saddr;
704 int i; 701 int i;
705 int retval = 0; 702 int retval = 0;
@@ -713,8 +710,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
713 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n", 710 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
714 __func__, sk, addrs, addrcnt); 711 __func__, sk, addrs, addrcnt);
715 712
716 list_for_each(pos, &ep->asocs) { 713 list_for_each_entry(asoc, &ep->asocs, asocs) {
717 asoc = list_entry(pos, struct sctp_association, asocs);
718 714
719 if (!asoc->peer.asconf_capable) 715 if (!asoc->peer.asconf_capable)
720 continue; 716 continue;
@@ -787,9 +783,8 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
787 * as some of the addresses in the bind address list are 783 * as some of the addresses in the bind address list are
788 * about to be deleted and cannot be used as source addresses. 784 * about to be deleted and cannot be used as source addresses.
789 */ 785 */
790 list_for_each(pos1, &asoc->peer.transport_addr_list) { 786 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
791 transport = list_entry(pos1, struct sctp_transport, 787 transports) {
792 transports);
793 dst_release(transport->dst); 788 dst_release(transport->dst);
794 sctp_transport_route(transport, NULL, 789 sctp_transport_route(transport, NULL,
795 sctp_sk(asoc->base.sk)); 790 sctp_sk(asoc->base.sk));
@@ -1397,7 +1392,6 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1397 long timeo; 1392 long timeo;
1398 __u16 sinfo_flags = 0; 1393 __u16 sinfo_flags = 0;
1399 struct sctp_datamsg *datamsg; 1394 struct sctp_datamsg *datamsg;
1400 struct list_head *pos;
1401 int msg_flags = msg->msg_flags; 1395 int msg_flags = msg->msg_flags;
1402 1396
1403 SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %zu)\n", 1397 SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %zu)\n",
@@ -1727,8 +1721,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1727 } 1721 }
1728 1722
1729 /* Now send the (possibly) fragmented message. */ 1723 /* Now send the (possibly) fragmented message. */
1730 list_for_each(pos, &datamsg->chunks) { 1724 list_for_each_entry(chunk, &datamsg->chunks, frag_list) {
1731 chunk = list_entry(pos, struct sctp_chunk, frag_list);
1732 sctp_chunk_hold(chunk); 1725 sctp_chunk_hold(chunk);
1733 1726
1734 /* Do accounting for the write space. */ 1727 /* Do accounting for the write space. */
@@ -2301,11 +2294,8 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
2301 * transport. 2294 * transport.
2302 */ 2295 */
2303 if (!trans && asoc) { 2296 if (!trans && asoc) {
2304 struct list_head *pos; 2297 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2305 2298 transports) {
2306 list_for_each(pos, &asoc->peer.transport_addr_list) {
2307 trans = list_entry(pos, struct sctp_transport,
2308 transports);
2309 sctp_apply_peer_addr_params(&params, trans, asoc, sp, 2299 sctp_apply_peer_addr_params(&params, trans, asoc, sp,
2310 hb_change, pmtud_change, 2300 hb_change, pmtud_change,
2311 sackdelay_change); 2301 sackdelay_change);
@@ -2396,11 +2386,8 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk,
2396 2386
2397 /* If change is for association, also apply to each transport. */ 2387 /* If change is for association, also apply to each transport. */
2398 if (asoc) { 2388 if (asoc) {
2399 struct list_head *pos; 2389 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2400 2390 transports) {
2401 list_for_each(pos, &asoc->peer.transport_addr_list) {
2402 trans = list_entry(pos, struct sctp_transport,
2403 transports);
2404 if (params.assoc_value) { 2391 if (params.assoc_value) {
2405 trans->sackdelay = 2392 trans->sackdelay =
2406 msecs_to_jiffies(params.assoc_value); 2393 msecs_to_jiffies(params.assoc_value);
@@ -2632,13 +2619,10 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, int o
2632 if (assocparams.sasoc_asocmaxrxt != 0) { 2619 if (assocparams.sasoc_asocmaxrxt != 0) {
2633 __u32 path_sum = 0; 2620 __u32 path_sum = 0;
2634 int paths = 0; 2621 int paths = 0;
2635 struct list_head *pos;
2636 struct sctp_transport *peer_addr; 2622 struct sctp_transport *peer_addr;
2637 2623
2638 list_for_each(pos, &asoc->peer.transport_addr_list) { 2624 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list,
2639 peer_addr = list_entry(pos, 2625 transports) {
2640 struct sctp_transport,
2641 transports);
2642 path_sum += peer_addr->pathmaxrxt; 2626 path_sum += peer_addr->pathmaxrxt;
2643 paths++; 2627 paths++;
2644 } 2628 }
@@ -2716,7 +2700,6 @@ static int sctp_setsockopt_mappedv4(struct sock *sk, char __user *optval, int op
2716static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optlen) 2700static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optlen)
2717{ 2701{
2718 struct sctp_association *asoc; 2702 struct sctp_association *asoc;
2719 struct list_head *pos;
2720 struct sctp_sock *sp = sctp_sk(sk); 2703 struct sctp_sock *sp = sctp_sk(sk);
2721 int val; 2704 int val;
2722 2705
@@ -2729,8 +2712,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optl
2729 sp->user_frag = val; 2712 sp->user_frag = val;
2730 2713
2731 /* Update the frag_point of the existing associations. */ 2714 /* Update the frag_point of the existing associations. */
2732 list_for_each(pos, &(sp->ep->asocs)) { 2715 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
2733 asoc = list_entry(pos, struct sctp_association, asocs);
2734 asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu); 2716 asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu);
2735 } 2717 }
2736 2718
@@ -4151,7 +4133,6 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
4151 int __user *optlen) 4133 int __user *optlen)
4152{ 4134{
4153 struct sctp_association *asoc; 4135 struct sctp_association *asoc;
4154 struct list_head *pos;
4155 int cnt = 0; 4136 int cnt = 0;
4156 struct sctp_getaddrs_old getaddrs; 4137 struct sctp_getaddrs_old getaddrs;
4157 struct sctp_transport *from; 4138 struct sctp_transport *from;
@@ -4176,8 +4157,8 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
4176 return -EINVAL; 4157 return -EINVAL;
4177 4158
4178 to = (void __user *)getaddrs.addrs; 4159 to = (void __user *)getaddrs.addrs;
4179 list_for_each(pos, &asoc->peer.transport_addr_list) { 4160 list_for_each_entry(from, &asoc->peer.transport_addr_list,
4180 from = list_entry(pos, struct sctp_transport, transports); 4161 transports) {
4181 memcpy(&temp, &from->ipaddr, sizeof(temp)); 4162 memcpy(&temp, &from->ipaddr, sizeof(temp));
4182 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4163 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4183 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 4164 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
@@ -4200,7 +4181,6 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4200 char __user *optval, int __user *optlen) 4181 char __user *optval, int __user *optlen)
4201{ 4182{
4202 struct sctp_association *asoc; 4183 struct sctp_association *asoc;
4203 struct list_head *pos;
4204 int cnt = 0; 4184 int cnt = 0;
4205 struct sctp_getaddrs getaddrs; 4185 struct sctp_getaddrs getaddrs;
4206 struct sctp_transport *from; 4186 struct sctp_transport *from;
@@ -4225,8 +4205,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4225 to = optval + offsetof(struct sctp_getaddrs,addrs); 4205 to = optval + offsetof(struct sctp_getaddrs,addrs);
4226 space_left = len - offsetof(struct sctp_getaddrs,addrs); 4206 space_left = len - offsetof(struct sctp_getaddrs,addrs);
4227 4207
4228 list_for_each(pos, &asoc->peer.transport_addr_list) { 4208 list_for_each_entry(from, &asoc->peer.transport_addr_list,
4229 from = list_entry(pos, struct sctp_transport, transports); 4209 transports) {
4230 memcpy(&temp, &from->ipaddr, sizeof(temp)); 4210 memcpy(&temp, &from->ipaddr, sizeof(temp));
4231 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4211 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4232 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 4212 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
@@ -6193,11 +6173,9 @@ do_nonblock:
6193void sctp_write_space(struct sock *sk) 6173void sctp_write_space(struct sock *sk)
6194{ 6174{
6195 struct sctp_association *asoc; 6175 struct sctp_association *asoc;
6196 struct list_head *pos;
6197 6176
6198 /* Wake up the tasks in each wait queue. */ 6177 /* Wake up the tasks in each wait queue. */
6199 list_for_each(pos, &((sctp_sk(sk))->ep->asocs)) { 6178 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) {
6200 asoc = list_entry(pos, struct sctp_association, asocs);
6201 __sctp_write_space(asoc); 6179 __sctp_write_space(asoc);
6202 } 6180 }
6203} 6181}