Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp3962190ooa; Mon, 13 Aug 2018 22:11:59 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwe5bEZqXmMIrip16F3LYbgaVbEYaF+0I6BZS2IJJJnE26B4bac8JgeVK85ZMjTAKYwXH5P X-Received: by 2002:a17:902:a713:: with SMTP id w19-v6mr18856572plq.271.1534223518985; Mon, 13 Aug 2018 22:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534223518; cv=none; d=google.com; s=arc-20160816; b=bdqyPGaTs78540Hw9fk2iyk3osQPRaiknnWDcmov3x4IPgbDZEe8vudqypL/WISN22 5qaKAH0RRYhZCLcOPLqTBy6EAAqzT7Q6rEldO7B3cMLIZdESA9psc/yPxA58cH7dsVwx TfpHSghv7GTfL7NN67SKQaA020gR10yISKjwQZ4tnjCoUJK9X5VJPyC9p/Rpp1d2lSxE JHR1pMo8rpd6ZJ93Z0m6vymecEJ2c0q8p0XjzMn4jBW+hjqlXWngPb9citR98ADLUgXL wss+1qW3njbOaL4IobhjO9l2UkyNuxjo7YdJsi1eBB4UgWCAI5QZ2H7sgNBxWk9QPCgY +JNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=wdVt9uoXKAw23DjLInLkTNMT5ZvVeHtJZj6o8M7KwSQ=; b=GxbBfTx63zF75lXWIL5UBQ3nlT59XV9HLsjDrXmSVxgVOIfIfLVQIlqwvVLueEfwAH hxJiaA4lz/W/bm/SBCGX/VvNuAh2vfQuZ7DNtC/pnlER042A60etLAaX+brofo1Mud0F D6ZGzss1mud9RkdYDHq+iWN+pk5xUNlQ0tEHGwE8KDpq1vGCVMHGwTny4Vpe2FNdr5EA De+eOi9hBXX1hr/IlQdePjkf3mRfl4QtMQbSiC4IHrQRvTaYMs4v5412rXgncijyVhob bDbCxpB0YmNFhgGNiLxp0EuZH+vq4ii9FkTOyirL6sF0CnOSSK+t9Sdyt+MjP6w1K6c+ nl/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d26-v6si19161505pgb.571.2018.08.13.22.11.31; Mon, 13 Aug 2018 22:11:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731858AbeHNHlq (ORCPT + 99 others); Tue, 14 Aug 2018 03:41:46 -0400 Received: from smtprelay0073.hostedemail.com ([216.40.44.73]:58896 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725999AbeHNHlq (ORCPT ); Tue, 14 Aug 2018 03:41:46 -0400 Received: from smtprelay.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by smtpgrave01.hostedemail.com (Postfix) with ESMTP id E7597180357FE; Tue, 14 Aug 2018 04:49:40 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 24BE2181D341D; Tue, 14 Aug 2018 04:49:40 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,golf@perches.com,:::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:4250:4321:5007:6737:7903:10004:10400:10848:11026:11232:11473:11658:11914:12043:12048:12296:12438:12555:12740:12760:12895:13439:14181:14659:14721:21080:21451:21627:30054:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:30,LUA_SUMMARY:none X-HE-Tag: shape15_19e6d385ddf31 X-Filterd-Recvd-Size: 3390 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Tue, 14 Aug 2018 04:49:37 +0000 (UTC) Message-ID: Subject: Re: [PATCH 2/2] powerpc: Use ARRAY_SIZE to replace its implementation From: Joe Perches To: zhong jiang , tony.luck@intel.com, fenghua.yu@intel.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, oleg@redhat.com, rppt@linux.vnet.ibm.com, dhowells@redhat.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Mon, 13 Aug 2018 21:49:36 -0700 In-Reply-To: <1534214814-9043-3-git-send-email-zhongjiang@huawei.com> References: <1534214814-9043-1-git-send-email-zhongjiang@huawei.com> <1534214814-9043-3-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-08-14 at 10:46 +0800, zhong jiang wrote: > Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element. > So just replace it. Better to remove the extern and the const altogether here as well. $ git grep -w powerpc_num_opcodes arch/powerpc/xmon/ppc-dis.c: opcode_end = powerpc_opcodes + powerpc_num_opcodes; arch/powerpc/xmon/ppc-opc.c:const int powerpc_num_opcodes = arch/powerpc/xmon/ppc.h:extern const int powerpc_num_opcodes; And this one could be removed instead: $ git grep -w vle_num_opcodes arch/powerpc/xmon/ppc-opc.c:const int vle_num_opcodes = arch/powerpc/xmon/ppc.h:extern const int vle_num_opcodes; > Signed-off-by: zhong jiang > --- > arch/powerpc/xmon/ppc-opc.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c > index ac2b55b..f3f57a1 100644 > --- a/arch/powerpc/xmon/ppc-opc.c > +++ b/arch/powerpc/xmon/ppc-opc.c > @@ -966,8 +966,7 @@ > { 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT }, > }; > > -const unsigned int num_powerpc_operands = (sizeof (powerpc_operands) > - / sizeof (powerpc_operands[0])); > +const unsigned int num_powerpc_operands = ARRAY_SIZE(powerpc_operands); > > /* The functions used to insert and extract complicated operands. */ > > @@ -6980,8 +6979,7 @@ > {"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}}, > }; > > -const int powerpc_num_opcodes = > - sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]); > +const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes); > > /* The VLE opcode table. > > @@ -7219,8 +7217,7 @@ > {"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}}, > }; > > -const int vle_num_opcodes = > - sizeof (vle_opcodes) / sizeof (vle_opcodes[0]); > +const int vle_num_opcodes = ARRAY_SIZE(vle_opcodes); > > /* The macro table. This is only used by the assembler. */ > > @@ -7288,5 +7285,4 @@ > {"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"}, > }; > > -const int powerpc_num_macros = > - sizeof (powerpc_macros) / sizeof (powerpc_macros[0]); > +const int powerpc_num_macros = ARRAY_SIZE(powerpc_macros);