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 <lirongq...@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