From patchwork Thu May 10 05:37:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li RongQing X-Patchwork-Id: 911286 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=baidu.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40hMSm6jwtz9s35 for ; Thu, 10 May 2018 15:38:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753523AbeEJFhy (ORCPT ); Thu, 10 May 2018 01:37:54 -0400 Received: from mx134-tc.baidu.com ([61.135.168.134]:57906 "EHLO tc-sys-mailedm01.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750758AbeEJFhx (ORCPT ); Thu, 10 May 2018 01:37:53 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm01.tc.baidu.com (Postfix) with ESMTP id 2699A2040041 for ; Thu, 10 May 2018 13:37:36 +0800 (CST) From: Li RongQing 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 Message-Id: <1525930656-6901-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.10.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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