All of lore.kernel.org
 help / color / mirror / Atom feed
* [v3] EDAC, sb_edac: Remove VLA usage
@ 2018-03-13 13:44 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-13 13:44 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Borislav Petkov
  Cc: linux-edac, linux-kernel, Gustavo A. R. Silva

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

Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v3:
 - Update macro MAX_INTERLEAVE in order to avoid too long lines.
   This change is based on Mauro's feedback.
 - Update changelog with Mauro's Reviewed-by.

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 8721002..aff4778 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -110,6 +110,11 @@ 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))))
+
 
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1904,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;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v3] EDAC, sb_edac: Remove VLA usage
@ 2018-03-13 13:44 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-13 13:44 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Borislav Petkov
  Cc: linux-edac, linux-kernel, Gustavo A. R. Silva

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

Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
Changes in v3:
 - Update macro MAX_INTERLEAVE in order to avoid too long lines.
   This change is based on Mauro's feedback.
 - Update changelog with Mauro's Reviewed-by.

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 8721002..aff4778 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -110,6 +110,11 @@ 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))))
+
 
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1904,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;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [v3] EDAC, sb_edac: Remove VLA usage
  2018-03-13 13:44 ` [PATCH v3] " Gustavo A. R. Silva
@ 2018-03-14 18:03 ` Borislav Petkov
  -1 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2018-03-14 18:03 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

On Tue, Mar 13, 2018 at 08:44:49AM -0500, Gustavo A. R. Silva wrote:
> 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
> 
> Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v3:
>  - Update macro MAX_INTERLEAVE in order to avoid too long lines.
>    This change is based on Mauro's feedback.
>  - Update changelog with Mauro's Reviewed-by.
> 
> 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 | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 8721002..aff4778 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -110,6 +110,11 @@ 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))))
> +
>  
>  struct interleave_pkg {
>  	unsigned char start;
> @@ -1899,7 +1904,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];

Where's the hunk removing ->max_interleave ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] EDAC, sb_edac: Remove VLA usage
@ 2018-03-14 18:03 ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2018-03-14 18:03 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

On Tue, Mar 13, 2018 at 08:44:49AM -0500, Gustavo A. R. Silva wrote:
> 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
> 
> Reviewed-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> Changes in v3:
>  - Update macro MAX_INTERLEAVE in order to avoid too long lines.
>    This change is based on Mauro's feedback.
>  - Update changelog with Mauro's Reviewed-by.
> 
> 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 | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
> index 8721002..aff4778 100644
> --- a/drivers/edac/sb_edac.c
> +++ b/drivers/edac/sb_edac.c
> @@ -110,6 +110,11 @@ 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))))
> +
>  
>  struct interleave_pkg {
>  	unsigned char start;
> @@ -1899,7 +1904,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];

Where's the hunk removing ->max_interleave ?

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [v3] EDAC, sb_edac: Remove VLA usage
  2018-03-14 18:03 ` [PATCH v3] " Borislav Petkov
@ 2018-03-14 18:23 ` Gustavo A. R. Silva
  -1 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-14 18:23 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

On 03/14/2018 01:03 PM, Borislav Petkov wrote:

[..]

>>   
>>   struct interleave_pkg {
>>   	unsigned char start;
>> @@ -1899,7 +1904,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];
> 
> Where's the hunk removing ->max_interleave ?
> 

Oh. I forgot to remove it.

I already sent v4: https://patchwork.kernel.org/patch/10283289/

Thanks
---
Gustavo
--
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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v3] EDAC, sb_edac: Remove VLA usage
@ 2018-03-14 18:23 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-14 18:23 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel



On 03/14/2018 01:03 PM, Borislav Petkov wrote:

[..]

>>   
>>   struct interleave_pkg {
>>   	unsigned char start;
>> @@ -1899,7 +1904,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];
> 
> Where's the hunk removing ->max_interleave ?
> 

Oh. I forgot to remove it.

I already sent v4: https://patchwork.kernel.org/patch/10283289/

Thanks
--
Gustavo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-14 18:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-13 13:44 [v3] EDAC, sb_edac: Remove VLA usage Gustavo A. R. Silva
2018-03-13 13:44 ` [PATCH v3] " Gustavo A. R. Silva
  -- strict thread matches above, loose matches on Subject: below --
2018-03-14 18:03 [v3] " Borislav Petkov
2018-03-14 18:03 ` [PATCH v3] " Borislav Petkov
2018-03-14 18:23 [v3] " Gustavo A. R. Silva
2018-03-14 18:23 ` [PATCH v3] " Gustavo A. R. Silva

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.