From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbdJBEQZ (ORCPT ); Mon, 2 Oct 2017 00:16:25 -0400 Received: from smtprelay0028.hostedemail.com ([216.40.44.28]:33799 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750760AbdJBEQY (ORCPT ); Mon, 2 Oct 2017 00:16:24 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:2914:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3872:4321:5007:10004:10400:10848:11232:11658:11914:12296:12740:12895:13069:13161:13229:13311:13357:13439:13894:14659:14721:21080:21627:30012:30025:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: snow69_71e318c453e2a X-Filterd-Recvd-Size: 1687 Message-ID: <1506917779.2274.9.camel@perches.com> Subject: Re: [PATCH 01/18] sound: use ARRAY_SIZE From: Joe Perches To: =?ISO-8859-1?Q?J=E9r=E9my?= Lefaure , Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Date: Sun, 01 Oct 2017 21:16:19 -0700 In-Reply-To: <20171001193101.8898-2-jeremy.lefaure@lse.epita.fr> References: <20171001193101.8898-1-jeremy.lefaure@lse.epita.fr> <20171001193101.8898-2-jeremy.lefaure@lse.epita.fr> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2017-10-01 at 15:30 -0400, Jérémy Lefaure wrote: > Using the ARRAY_SIZE macro improves the readability of the code. > > Found with Coccinelle with the following semantic patch: > @r depends on (org || report)@ > type T; > T[] E; > position p; > @@ > ( > (sizeof(E)@p /sizeof(*E)) > > > > (sizeof(E)@p /sizeof(E[...])) > > > > (sizeof(E)@p /sizeof(T)) > ) [] > diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c [] > @@ -797,7 +798,7 @@ static int ad1848_set_speed(int dev, int arg) > > int i, n, selected = -1; > > - n = sizeof(speed_table) / sizeof(speed_struct); > + n = ARRAY_SIZE(speed_table); These sorts of changes are OK, but for many uses, it's more readable to use ARRAY_SIZE(foo) in each location rather than using a temporary.