From e40d14a89760632238f67c1f96c852652a137f2d Mon Sep 17 00:00:00 2001 From: Jérémy Lefaure Date: Sun, 1 Oct 2017 15:30:41 -0400 Subject: media: use ARRAY_SIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the ARRAY_SIZE macro improves the readability of the code. Also, it is not always useful to use a variable to store this constant calculated at compile time. 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)) ) Signed-off-by: Jérémy Lefaure Reviewed-by: Michael Ira Krufky Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb-frontends/cxd2841er.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/media/dvb-frontends') diff --git a/drivers/media/dvb-frontends/cxd2841er.c b/drivers/media/dvb-frontends/cxd2841er.c index 48ee9bc00c06..2cb97a3130be 100644 --- a/drivers/media/dvb-frontends/cxd2841er.c +++ b/drivers/media/dvb-frontends/cxd2841er.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "dvb_math.h" #include "dvb_frontend.h" @@ -1696,12 +1697,10 @@ static u32 cxd2841er_dvbs_read_snr(struct cxd2841er_priv *priv, min_index = 0; if (delsys == SYS_DVBS) { cn_data = s_cn_data; - max_index = sizeof(s_cn_data) / - sizeof(s_cn_data[0]) - 1; + max_index = ARRAY_SIZE(s_cn_data) - 1; } else { cn_data = s2_cn_data; - max_index = sizeof(s2_cn_data) / - sizeof(s2_cn_data[0]) - 1; + max_index = ARRAY_SIZE(s2_cn_data) - 1; } if (value >= cn_data[min_index].value) { res = cn_data[min_index].cnr_x1000; -- cgit