linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] EDAC, sb_edac: Remove VLA usage
@ 2018-03-10  3:02 Gustavo A. R. Silva
  2018-03-10 14:04 ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-10  3:02 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

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---

Notice that due to this change, the field max_interleave is no longer
used after it has been initialized. Maybe it should be removed?

Thanks
--
Gustavo
---
 drivers/edac/sb_edac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 8721002..11cb2c9 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -110,6 +110,7 @@ static const u32 knl_interleave_list[] = {
 	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
 	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
 };
+#define MAX_INTERLEAVE	ARRAY_SIZE(knl_interleave_list)
 
 struct interleave_pkg {
 	unsigned char start;
@@ -1899,7 +1900,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] 5+ messages in thread

* Re: [PATCH] EDAC, sb_edac: Remove VLA usage
  2018-03-10  3:02 [PATCH] EDAC, sb_edac: Remove VLA usage Gustavo A. R. Silva
@ 2018-03-10 14:04 ` Borislav Petkov
  2018-03-12 22:52   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2018-03-10 14:04 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

On Fri, Mar 09, 2018 at 09:02:18PM -0600, 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
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
> ---
> 
> Notice that due to this change, the field max_interleave is no longer
> used after it has been initialized. Maybe it should be removed?

Yes.

> @@ -110,6 +110,7 @@ static const u32 knl_interleave_list[] = {
>  	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
>  	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
>  };
> +#define MAX_INTERLEAVE	ARRAY_SIZE(knl_interleave_list)

define that as the max of all interleave lists array sizes so that
people can update it properly when new interleave lists get added.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH] EDAC, sb_edac: Remove VLA usage
  2018-03-10 14:04 ` Borislav Petkov
@ 2018-03-12 22:52   ` Gustavo A. R. Silva
  2018-03-13 10:48     ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-12 22:52 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

Hi Borislav,

On 03/10/2018 08:04 AM, Borislav Petkov wrote:
> On Fri, Mar 09, 2018 at 09:02:18PM -0600, 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
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>> ---
>>
>> Notice that due to this change, the field max_interleave is no longer
>> used after it has been initialized. Maybe it should be removed?
> 
> Yes.
> 

I'll remove it then.

>> @@ -110,6 +110,7 @@ static const u32 knl_interleave_list[] = {
>>   	0xdc, 0xe4, 0xec, 0xf4, 0xfc, /* 15-19 */
>>   	0x104, 0x10c, 0x114, 0x11c,   /* 20-23 */
>>   };
>> +#define MAX_INTERLEAVE	ARRAY_SIZE(knl_interleave_list)
> 
> define that as the max of all interleave lists array sizes so that
> people can update it properly when new interleave lists get added.
> 

Do you mean just adding a code comment?

Thanks for the feedback.
--
Gustavo

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

* Re: [PATCH] EDAC, sb_edac: Remove VLA usage
  2018-03-12 22:52   ` Gustavo A. R. Silva
@ 2018-03-13 10:48     ` Borislav Petkov
  2018-03-13 11:08       ` Gustavo A. R. Silva
  0 siblings, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2018-03-13 10:48 UTC (permalink / raw)
  To: Gustavo A. R. Silva; +Cc: Mauro Carvalho Chehab, linux-edac, linux-kernel

On Mon, Mar 12, 2018 at 05:52:13PM -0500, Gustavo A. R. Silva wrote:
> Do you mean just adding a code comment?

No, I mean

#define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(knl_interleave_list), ...

which computes the max of all three array sizes.

Thx.

-- 
Regards/Gruss,
    Boris.

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

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

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



On 03/13/2018 05:48 AM, Borislav Petkov wrote:
> On Mon, Mar 12, 2018 at 05:52:13PM -0500, Gustavo A. R. Silva wrote:
>> Do you mean just adding a code comment?
> 
> No, I mean
> 
> #define MAX_INTERLEAVE (max_t(unsigned int, ARRAY_SIZE(knl_interleave_list), ...
> 
> which computes the max of all three array sizes.
> 
> Thx.
> 

I got it.

Exactly this:

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


I'll send v2 shortly.

Thanks!
--
Gustavo

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

end of thread, other threads:[~2018-03-13 11:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-10  3:02 [PATCH] EDAC, sb_edac: Remove VLA usage Gustavo A. R. Silva
2018-03-10 14:04 ` Borislav Petkov
2018-03-12 22:52   ` Gustavo A. R. Silva
2018-03-13 10:48     ` Borislav Petkov
2018-03-13 11:08       ` Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).