All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Borislav Petkov <bp@alien8.de>,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [v2] EDAC, sb_edac: Remove VLA usage
Date: Tue, 13 Mar 2018 10:21:33 -0300	[thread overview]
Message-ID: <20180313102133.7e505e2b@vento.lan> (raw)

Em Tue, 13 Mar 2018 06:20:34 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> escreveu:

> In preparation to enabling -Wvla, remove VLA and replace it
> with a fixed-length array instead.
> 
> Fixed as part of the directive to remove all VLAs from
> the kernel: https://lkml.org/lkml/2018/3/7/621
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  - Use macro max_t to compute the max of all three array sizes.
>    This change is based on Borislav's feedback.
> 
>  drivers/edac/sb_edac.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 8721002..196b012 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -110,6 +110,10 @@ static const u32 knl_interleave_list[] = {
>  	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
>  	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
>  };
> +#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),\
> +			max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list),\
> +					    ARRAY_SIZE(knl_interleave_list))))
> +

In order to avoid too long lines, it would be better to do it as:

#define MAX_INTERLEAVE						        \
	(max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),       \
	       max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list), \
		     ARRAY_SIZE(knl_interleave_list))))


With that:

Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

>  
>  struct interleave_pkg {
>  	unsigned char start;
> @@ -1899,7 +1903,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
>  	int			n_rir, n_sads, n_tads, sad_way, sck_xch;
>  	int			sad_interl, idx, base_ch;
>  	int			interleave_mode, shiftup = 0;
> -	unsigned		sad_interleave[pvt->info.max_interleave];
> +	unsigned int		sad_interleave[MAX_INTERLEAVE];
>  	u32			reg, dram_rule;
>  	u8			ch_way, sck_way, pkg, sad_ha = 0;
>  	u32			tad_offset;



Thanks,
Mauro
---
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Borislav Petkov <bp@alien8.de>,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] EDAC, sb_edac: Remove VLA usage
Date: Tue, 13 Mar 2018 10:21:33 -0300	[thread overview]
Message-ID: <20180313102133.7e505e2b@vento.lan> (raw)
In-Reply-To: <20180313112034.GA28234@embeddedgus>

Em Tue, 13 Mar 2018 06:20:34 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> escreveu:

> In preparation to enabling -Wvla, remove VLA and replace it
> with a fixed-length array instead.
> 
> Fixed as part of the directive to remove all VLAs from
> the kernel: https://lkml.org/lkml/2018/3/7/621
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v2:
>  - Use macro max_t to compute the max of all three array sizes.
>    This change is based on Borislav's feedback.
> 
>  drivers/edac/sb_edac.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 8721002..196b012 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -110,6 +110,10 @@ static const u32 knl_interleave_list[] = {
>  	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
>  	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
>  };
> +#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),\
> +			max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list),\
> +					    ARRAY_SIZE(knl_interleave_list))))
> +

In order to avoid too long lines, it would be better to do it as:

#define MAX_INTERLEAVE						        \
	(max_t(unsigned int, ARRAY_SIZE(sbridge_interleave_list),       \
	       max_t(unsigned int, ARRAY_SIZE(ibridge_interleave_list), \
		     ARRAY_SIZE(knl_interleave_list))))


With that:

Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

>  
>  struct interleave_pkg {
>  	unsigned char start;
> @@ -1899,7 +1903,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
>  	int			n_rir, n_sads, n_tads, sad_way, sck_xch;
>  	int			sad_interl, idx, base_ch;
>  	int			interleave_mode, shiftup = 0;
> -	unsigned		sad_interleave[pvt->info.max_interleave];
> +	unsigned int		sad_interleave[MAX_INTERLEAVE];
>  	u32			reg, dram_rule;
>  	u8			ch_way, sck_way, pkg, sad_ha = 0;
>  	u32			tad_offset;



Thanks,
Mauro

             reply	other threads:[~2018-03-13 13:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-13 13:21 Mauro Carvalho Chehab [this message]
2018-03-13 13:21 ` [PATCH v2] EDAC, sb_edac: Remove VLA usage Mauro Carvalho Chehab
  -- strict thread matches above, loose matches on Subject: below --
2018-03-13 13:30 [v2] " Gustavo A. R. Silva
2018-03-13 13:30 ` [PATCH v2] " Gustavo A. R. Silva
2018-03-13 11:20 [v2] " Gustavo A. R. Silva
2018-03-13 11:20 ` [PATCH v2] " Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180313102133.7e505e2b@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=bp@alien8.de \
    --cc=gustavo@embeddedor.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.