[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1506917779.2274.9.camel@perches.com>
Date: Sun, 01 Oct 2017 21:16:19 -0700
From: Joe Perches <joe@...ches.com>
To: Jérémy Lefaure <jeremy.lefaure@....epita.fr>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: alsa-devel@...a-project.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 01/18] sound: use ARRAY_SIZE
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.
Powered by blists - more mailing lists