From: Li RongQing <lirongqing@baidu.com>
To: netdev@vger.kernel.org
Subject: [net-next][PATCH] inet: Use switch case instead of multiple condition checks
Date: Thu, 10 May 2018 13:37:36 +0800 [thread overview]
Message-ID: <1525930656-6901-1-git-send-email-lirongqing@baidu.com> (raw)
inet_csk_reset_xmit_timer uses multiple equality condition checks,
so it is better to use switch case instead of them
after this patch, the increased image size is acceptable
Before After
size of net/ipv4/tcp_output.o: 721640 721648
size of vmlinux: 400236400 400236401
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
include/net/inet_connection_sock.h | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 2ab6667275df..d2e9314cf43d 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -239,22 +239,31 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,
when = max_when;
}
- if (what == ICSK_TIME_RETRANS || what == ICSK_TIME_PROBE0 ||
- what == ICSK_TIME_EARLY_RETRANS || what == ICSK_TIME_LOSS_PROBE ||
- what == ICSK_TIME_REO_TIMEOUT) {
+ switch (what) {
+ case ICSK_TIME_RETRANS:
+ /* fall through */
+ case ICSK_TIME_PROBE0:
+ /* fall through */
+ case ICSK_TIME_EARLY_RETRANS:
+ /* fall through */
+ case ICSK_TIME_LOSS_PROBE:
+ /* fall through */
+ case ICSK_TIME_REO_TIMEOUT:
icsk->icsk_pending = what;
icsk->icsk_timeout = jiffies + when;
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout);
- } else if (what == ICSK_TIME_DACK) {
+ break;
+ case ICSK_TIME_DACK:
icsk->icsk_ack.pending |= ICSK_ACK_TIMER;
icsk->icsk_ack.timeout = jiffies + when;
sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout);
- }
+ break;
#ifdef INET_CSK_DEBUG
- else {
+ default:
pr_debug("%s", inet_csk_timer_bug_msg);
- }
+ break;
#endif
+ }
}
static inline unsigned long
--
2.16.2
next reply other threads:[~2018-05-10 5:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-10 5:37 Li RongQing [this message]
2018-05-10 5:48 ` [net-next][PATCH] inet: Use switch case instead of multiple condition checks Eric Dumazet
2018-05-10 5:49 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1525930656-6901-1-git-send-email-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox