diff options
author | Allan Stephens <Allan.Stephens@windriver.com> | 2010-12-31 13:59:33 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-01-01 16:57:56 -0500 |
commit | 2db9983a4318818845193bd577879c0620705e82 (patch) | |
tree | a77ed030edde71edb1c1b781f580cdfd642ac70d | |
parent | 0e65967e33be61e5f67727edd4ea829b47676fc0 (diff) |
tipc: split variable assignments out of conditional expressions
Cleans up TIPC's source code to eliminate assigning values to variables
within conditional expressions, improving code readability and reducing
warnings from various code checker tools.
These changes are purely cosmetic and do not alter the operation of TIPC
in any way.
Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/bearer.c | 3 | ||||
-rw-r--r-- | net/tipc/core.c | 33 | ||||
-rw-r--r-- | net/tipc/link.c | 16 | ||||
-rw-r--r-- | net/tipc/socket.c | 36 |
4 files changed, 56 insertions, 32 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 040f3ed32ec8..e9136f0abe60 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -251,7 +251,8 @@ static int bearer_name_validate(const char *name, | |||
251 | /* ensure all component parts of bearer name are present */ | 251 | /* ensure all component parts of bearer name are present */ |
252 | 252 | ||
253 | media_name = name_copy; | 253 | media_name = name_copy; |
254 | if ((if_name = strchr(media_name, ':')) == NULL) | 254 | if_name = strchr(media_name, ':'); |
255 | if (if_name == NULL) | ||
255 | return 0; | 256 | return 0; |
256 | *(if_name++) = 0; | 257 | *(if_name++) = 0; |
257 | media_len = if_name - media_name; | 258 | media_len = if_name - media_name; |
diff --git a/net/tipc/core.c b/net/tipc/core.c index 60b85ec6d106..e071579e0850 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
@@ -115,10 +115,11 @@ int tipc_core_start_net(unsigned long addr) | |||
115 | { | 115 | { |
116 | int res; | 116 | int res; |
117 | 117 | ||
118 | if ((res = tipc_net_start(addr)) || | 118 | res = tipc_net_start(addr); |
119 | (res = tipc_eth_media_start())) { | 119 | if (!res) |
120 | res = tipc_eth_media_start(); | ||
121 | if (res) | ||
120 | tipc_core_stop_net(); | 122 | tipc_core_stop_net(); |
121 | } | ||
122 | return res; | 123 | return res; |
123 | } | 124 | } |
124 | 125 | ||
@@ -157,15 +158,22 @@ static int tipc_core_start(void) | |||
157 | get_random_bytes(&tipc_random, sizeof(tipc_random)); | 158 | get_random_bytes(&tipc_random, sizeof(tipc_random)); |
158 | tipc_mode = TIPC_NODE_MODE; | 159 | tipc_mode = TIPC_NODE_MODE; |
159 | 160 | ||
160 | if ((res = tipc_handler_start()) || | 161 | res = tipc_handler_start(); |
161 | (res = tipc_ref_table_init(tipc_max_ports, tipc_random)) || | 162 | if (!res) |
162 | (res = tipc_nametbl_init()) || | 163 | res = tipc_ref_table_init(tipc_max_ports, tipc_random); |
163 | (res = tipc_k_signal((Handler)tipc_subscr_start, 0)) || | 164 | if (!res) |
164 | (res = tipc_k_signal((Handler)tipc_cfg_init, 0)) || | 165 | res = tipc_nametbl_init(); |
165 | (res = tipc_netlink_start()) || | 166 | if (!res) |
166 | (res = tipc_socket_init())) { | 167 | res = tipc_k_signal((Handler)tipc_subscr_start, 0); |
168 | if (!res) | ||
169 | res = tipc_k_signal((Handler)tipc_cfg_init, 0); | ||
170 | if (!res) | ||
171 | res = tipc_netlink_start(); | ||
172 | if (!res) | ||
173 | res = tipc_socket_init(); | ||
174 | if (res) | ||
167 | tipc_core_stop(); | 175 | tipc_core_stop(); |
168 | } | 176 | |
169 | return res; | 177 | return res; |
170 | } | 178 | } |
171 | 179 | ||
@@ -188,7 +196,8 @@ static int __init tipc_init(void) | |||
188 | tipc_max_nodes = CONFIG_TIPC_NODES; | 196 | tipc_max_nodes = CONFIG_TIPC_NODES; |
189 | tipc_net_id = 4711; | 197 | tipc_net_id = 4711; |
190 | 198 | ||
191 | if ((res = tipc_core_start())) | 199 | res = tipc_core_start(); |
200 | if (res) | ||
192 | err("Unable to start in single node mode\n"); | 201 | err("Unable to start in single node mode\n"); |
193 | else | 202 | else |
194 | info("Started in single node mode\n"); | 203 | info("Started in single node mode\n"); |
diff --git a/net/tipc/link.c b/net/tipc/link.c index ef203a1581cd..de9d49108d41 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -187,14 +187,17 @@ static int link_name_validate(const char *name, struct link_name *name_parts) | |||
187 | /* ensure all component parts of link name are present */ | 187 | /* ensure all component parts of link name are present */ |
188 | 188 | ||
189 | addr_local = name_copy; | 189 | addr_local = name_copy; |
190 | if ((if_local = strchr(addr_local, ':')) == NULL) | 190 | if_local = strchr(addr_local, ':'); |
191 | if (if_local == NULL) | ||
191 | return 0; | 192 | return 0; |
192 | *(if_local++) = 0; | 193 | *(if_local++) = 0; |
193 | if ((addr_peer = strchr(if_local, '-')) == NULL) | 194 | addr_peer = strchr(if_local, '-'); |
195 | if (addr_peer == NULL) | ||
194 | return 0; | 196 | return 0; |
195 | *(addr_peer++) = 0; | 197 | *(addr_peer++) = 0; |
196 | if_local_len = addr_peer - if_local; | 198 | if_local_len = addr_peer - if_local; |
197 | if ((if_peer = strchr(addr_peer, ':')) == NULL) | 199 | if_peer = strchr(addr_peer, ':'); |
200 | if (if_peer == NULL) | ||
198 | return 0; | 201 | return 0; |
199 | *(if_peer++) = 0; | 202 | *(if_peer++) = 0; |
200 | if_peer_len = strlen(if_peer) + 1; | 203 | if_peer_len = strlen(if_peer) + 1; |
@@ -2044,8 +2047,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) | |||
2044 | 2047 | ||
2045 | strcpy((strrchr(l_ptr->name, ':') + 1), (char *)msg_data(msg)); | 2048 | strcpy((strrchr(l_ptr->name, ':') + 1), (char *)msg_data(msg)); |
2046 | 2049 | ||
2047 | if ((msg_tol = msg_link_tolerance(msg)) && | 2050 | msg_tol = msg_link_tolerance(msg); |
2048 | (msg_tol > l_ptr->tolerance)) | 2051 | if (msg_tol > l_ptr->tolerance) |
2049 | link_set_supervision_props(l_ptr, msg_tol); | 2052 | link_set_supervision_props(l_ptr, msg_tol); |
2050 | 2053 | ||
2051 | if (msg_linkprio(msg) > l_ptr->priority) | 2054 | if (msg_linkprio(msg) > l_ptr->priority) |
@@ -2074,7 +2077,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) | |||
2074 | break; | 2077 | break; |
2075 | case STATE_MSG: | 2078 | case STATE_MSG: |
2076 | 2079 | ||
2077 | if ((msg_tol = msg_link_tolerance(msg))) | 2080 | msg_tol = msg_link_tolerance(msg); |
2081 | if (msg_tol) | ||
2078 | link_set_supervision_props(l_ptr, msg_tol); | 2082 | link_set_supervision_props(l_ptr, msg_tol); |
2079 | 2083 | ||
2080 | if (msg_linkprio(msg) && | 2084 | if (msg_linkprio(msg) && |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index e9fc5df79eb0..0895dec2967c 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -563,7 +563,8 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
563 | 563 | ||
564 | do { | 564 | do { |
565 | if (dest->addrtype == TIPC_ADDR_NAME) { | 565 | if (dest->addrtype == TIPC_ADDR_NAME) { |
566 | if ((res = dest_name_check(dest, m))) | 566 | res = dest_name_check(dest, m); |
567 | if (res) | ||
567 | break; | 568 | break; |
568 | res = tipc_send2name(tport->ref, | 569 | res = tipc_send2name(tport->ref, |
569 | &dest->addr.name.name, | 570 | &dest->addr.name.name, |
@@ -580,7 +581,8 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, | |||
580 | res = -EOPNOTSUPP; | 581 | res = -EOPNOTSUPP; |
581 | break; | 582 | break; |
582 | } | 583 | } |
583 | if ((res = dest_name_check(dest, m))) | 584 | res = dest_name_check(dest, m); |
585 | if (res) | ||
584 | break; | 586 | break; |
585 | res = tipc_multicast(tport->ref, | 587 | res = tipc_multicast(tport->ref, |
586 | &dest->addr.nameseq, | 588 | &dest->addr.nameseq, |
@@ -750,7 +752,8 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, | |||
750 | bytes_to_send = curr_left; | 752 | bytes_to_send = curr_left; |
751 | my_iov.iov_base = curr_start; | 753 | my_iov.iov_base = curr_start; |
752 | my_iov.iov_len = bytes_to_send; | 754 | my_iov.iov_len = bytes_to_send; |
753 | if ((res = send_packet(NULL, sock, &my_msg, 0)) < 0) { | 755 | res = send_packet(NULL, sock, &my_msg, 0); |
756 | if (res < 0) { | ||
754 | if (bytes_sent) | 757 | if (bytes_sent) |
755 | res = bytes_sent; | 758 | res = bytes_sent; |
756 | goto exit; | 759 | goto exit; |
@@ -845,12 +848,15 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
845 | if (unlikely(err)) { | 848 | if (unlikely(err)) { |
846 | anc_data[0] = err; | 849 | anc_data[0] = err; |
847 | anc_data[1] = msg_data_sz(msg); | 850 | anc_data[1] = msg_data_sz(msg); |
848 | if ((res = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, anc_data))) | 851 | res = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, anc_data); |
849 | return res; | 852 | if (res) |
850 | if (anc_data[1] && | ||
851 | (res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1], | ||
852 | msg_data(msg)))) | ||
853 | return res; | 853 | return res; |
854 | if (anc_data[1]) { | ||
855 | res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1], | ||
856 | msg_data(msg)); | ||
857 | if (res) | ||
858 | return res; | ||
859 | } | ||
854 | } | 860 | } |
855 | 861 | ||
856 | /* Optionally capture message destination object */ | 862 | /* Optionally capture message destination object */ |
@@ -878,9 +884,11 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, | |||
878 | default: | 884 | default: |
879 | has_name = 0; | 885 | has_name = 0; |
880 | } | 886 | } |
881 | if (has_name && | 887 | if (has_name) { |
882 | (res = put_cmsg(m, SOL_TIPC, TIPC_DESTNAME, 12, anc_data))) | 888 | res = put_cmsg(m, SOL_TIPC, TIPC_DESTNAME, 12, anc_data); |
883 | return res; | 889 | if (res) |
890 | return res; | ||
891 | } | ||
884 | 892 | ||
885 | return 0; | 893 | return 0; |
886 | } | 894 | } |
@@ -1664,7 +1672,8 @@ static int setsockopt(struct socket *sock, | |||
1664 | return -ENOPROTOOPT; | 1672 | return -ENOPROTOOPT; |
1665 | if (ol < sizeof(value)) | 1673 | if (ol < sizeof(value)) |
1666 | return -EINVAL; | 1674 | return -EINVAL; |
1667 | if ((res = get_user(value, (u32 __user *)ov))) | 1675 | res = get_user(value, (u32 __user *)ov); |
1676 | if (res) | ||
1668 | return res; | 1677 | return res; |
1669 | 1678 | ||
1670 | lock_sock(sk); | 1679 | lock_sock(sk); |
@@ -1722,7 +1731,8 @@ static int getsockopt(struct socket *sock, | |||
1722 | return put_user(0, ol); | 1731 | return put_user(0, ol); |
1723 | if (lvl != SOL_TIPC) | 1732 | if (lvl != SOL_TIPC) |
1724 | return -ENOPROTOOPT; | 1733 | return -ENOPROTOOPT; |
1725 | if ((res = get_user(len, ol))) | 1734 | res = get_user(len, ol); |
1735 | if (res) | ||
1726 | return res; | 1736 | return res; |
1727 | 1737 | ||
1728 | lock_sock(sk); | 1738 | lock_sock(sk); |