aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2006-11-27 09:26:03 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:30:38 -0500
commit7da7f456d7bc0e52009f882e8af0ac910293e157 (patch)
treec49cecb21030022b951fcdeed98728782f37d034
parent91cf5a17257e1d2ef936fbf0223c3436ca583af9 (diff)
[DCCP] ccid3: Simplify control flow of ccid3_hc_tx_send_packet
This makes some logically equivalent simplifications, by replacing rc - values plus goto's with direct return statements. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
-rw-r--r--net/dccp/ccids/ccid3.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index fb1a5e89c023..2745d835f037 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -247,6 +247,12 @@ out:
247 sock_put(sk); 247 sock_put(sk);
248} 248}
249 249
250/*
251 * returns
252 * > 0: delay (in msecs) that should pass before actually sending
253 * = 0: can send immediately
254 * < 0: error condition; do not send packet
255 */
250static int ccid3_hc_tx_send_packet(struct sock *sk, 256static int ccid3_hc_tx_send_packet(struct sock *sk,
251 struct sk_buff *skb, int len) 257 struct sk_buff *skb, int len)
252{ 258{
@@ -255,7 +261,6 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
255 struct dccp_tx_hist_entry *new_packet; 261 struct dccp_tx_hist_entry *new_packet;
256 struct timeval now; 262 struct timeval now;
257 long delay; 263 long delay;
258 int rc = -ENOTCONN;
259 264
260 BUG_ON(hctx == NULL); 265 BUG_ON(hctx == NULL);
261 266
@@ -265,7 +270,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
265 * packets can have zero length, but why the comment about "pure ACK"? 270 * packets can have zero length, but why the comment about "pure ACK"?
266 */ 271 */
267 if (unlikely(len == 0)) 272 if (unlikely(len == 0))
268 goto out; 273 return -ENOTCONN;
269 274
270 /* See if last packet allocated was not sent */ 275 /* See if last packet allocated was not sent */
271 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 276 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
@@ -273,11 +278,10 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
273 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, 278 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
274 SLAB_ATOMIC); 279 SLAB_ATOMIC);
275 280
276 rc = -ENOBUFS;
277 if (unlikely(new_packet == NULL)) { 281 if (unlikely(new_packet == NULL)) {
278 DCCP_WARN("%s, sk=%p, not enough mem to add to history," 282 DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
279 "send refused\n", dccp_role(sk), sk); 283 "send refused\n", dccp_role(sk), sk);
280 goto out; 284 return -ENOBUFS;
281 } 285 }
282 286
283 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); 287 dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet);
@@ -300,7 +304,6 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
300 304
301 /* Set t_0 for initial packet */ 305 /* Set t_0 for initial packet */
302 hctx->ccid3hctx_t_nom = now; 306 hctx->ccid3hctx_t_nom = now;
303 rc = 0;
304 break; 307 break;
305 case TFRC_SSTATE_NO_FBACK: 308 case TFRC_SSTATE_NO_FBACK:
306 case TFRC_SSTATE_FBACK: 309 case TFRC_SSTATE_FBACK:
@@ -313,28 +316,21 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
313 * else 316 * else
314 * // send the packet in (t_nom - t_now) milliseconds. 317 * // send the packet in (t_nom - t_now) milliseconds.
315 */ 318 */
316 if (delay < hctx->ccid3hctx_delta) 319 if (delay >= hctx->ccid3hctx_delta)
317 rc = 0; 320 return delay / 1000L;
318 else
319 rc = delay/1000L;
320 break; 321 break;
321 case TFRC_SSTATE_TERM: 322 case TFRC_SSTATE_TERM:
322 DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk); 323 DCCP_BUG("Illegal %s state TERM, sk=%p", dccp_role(sk), sk);
323 rc = -EINVAL; 324 return -EINVAL;
324 break;
325 } 325 }
326 326
327 /* Can we send? if so add options and add to packet history */ 327 /* prepare to send now (add options etc.) */
328 if (rc == 0) { 328 dp->dccps_hc_tx_insert_options = 1;
329 dp->dccps_hc_tx_insert_options = 1; 329 new_packet->dccphtx_ccval = DCCP_SKB_CB(skb)->dccpd_ccval =
330 new_packet->dccphtx_ccval = 330 hctx->ccid3hctx_last_win_count;
331 DCCP_SKB_CB(skb)->dccpd_ccval = 331 timeval_add_usecs(&hctx->ccid3hctx_t_nom, hctx->ccid3hctx_t_ipi);
332 hctx->ccid3hctx_last_win_count; 332
333 timeval_add_usecs(&hctx->ccid3hctx_t_nom, 333 return 0;
334 hctx->ccid3hctx_t_ipi);
335 }
336out:
337 return rc;
338} 334}
339 335
340static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) 336static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)