From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbdGDSeJ (ORCPT ); Tue, 4 Jul 2017 14:34:09 -0400 Received: from gateway33.websitewelcome.com ([192.185.145.239]:38759 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751960AbdGDSeI (ORCPT ); Tue, 4 Jul 2017 14:34:08 -0400 Date: Tue, 4 Jul 2017 13:34:05 -0500 From: "Gustavo A. R. Silva" To: Boris Ostrovsky , Juergen Gross Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Message-ID: <20170704183404.GA13813@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.164.199 X-Exim-ID: 1dSSeD-000ST1-Nj X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.164.199]:53564 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 4 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove unnecessary static on local variables last_frontswap_pages and tgt_frontswap_pages. Such variables are initialized before being used, on every execution path throughout the function. The statics have no benefit and, removing them reduce the code size. This issue was detected using Coccinelle and the following semantic patch: @bad exists@ position p; identifier x; type T; @@ static T x@p; ... x = <+...x...+> @@ identifier x; expression e; type T; position p != bad.p; @@ -static T x@p; ... when != x when strict ?x = e; You can see a significant difference in the code size after executing the size command, before and after the code change: before: text data bss dec hex filename 5633 3452 384 9469 24fd drivers/xen/xen-selfballoon.o after: text data bss dec hex filename 5576 3308 256 9140 23b4 drivers/xen/xen-selfballoon.o Signed-off-by: Gustavo A. R. Silva --- drivers/xen/xen-selfballoon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c index 6662071..a67e955 100644 --- a/drivers/xen/xen-selfballoon.c +++ b/drivers/xen/xen-selfballoon.c @@ -151,8 +151,8 @@ static unsigned long frontswap_inertia_counter; static void frontswap_selfshrink(void) { static unsigned long cur_frontswap_pages; - static unsigned long last_frontswap_pages; - static unsigned long tgt_frontswap_pages; + unsigned long last_frontswap_pages; + unsigned long tgt_frontswap_pages; last_frontswap_pages = cur_frontswap_pages; cur_frontswap_pages = frontswap_curr_pages(); -- 2.5.0