Message ID | 20180309061152.r3yumh6agasyhtvo@cisco (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
I sent a patch for this six hours ago: https://patchwork.kernel.org/patch/10268591/ -- Gustavo On 03/09/2018 12:11 AM, Tycho Andersen wrote: > On Thu, Mar 08, 2018 at 10:01:07PM -0800, Joe Perches wrote: >> On Fri, 2018-03-09 at 16:50 +1100, Tobin C. Harding wrote: >>> The kernel would like to have all stack VLA usage removed[1]. The >>> arrays are fixed here (declared with a const variable) but they appear >>> like VLAs to the compiler. We can use a pre-processor define to fix the >>> warning. >> [] >>> diff --git a/drivers/video/fbdev/via/via_aux_sii164.c b/drivers/video/fbdev/via/via_aux_sii164.c >> [] >>> @@ -27,6 +27,9 @@ >>> >>> static const char *name = "SiI 164 PanelLink Transmitter"; >>> >>> +/* check vendor id and device id */ >>> +const u8 id[] = {0x01, 0x00, 0x06, 0x00}; >> >> It seems id is now global in multiple places. >> Perhaps these should be static. > > Does it even need to be global? Why not just get rid of the indirection and use > ARRAY_SIZE where we mean it? This seems to work for me, > > diff --git a/drivers/video/fbdev/via/via_aux_sii164.c b/drivers/video/fbdev/via/via_aux_sii164.c > index ca1b35f033b1..87db6c98d680 100644 > --- a/drivers/video/fbdev/via/via_aux_sii164.c > +++ b/drivers/video/fbdev/via/via_aux_sii164.c > @@ -35,10 +35,10 @@ static void probe(struct via_aux_bus *bus, u8 addr) > .addr = addr, > .name = name}; > /* check vendor id and device id */ > - const u8 id[] = {0x01, 0x00, 0x06, 0x00}, len = ARRAY_SIZE(id); > - u8 tmp[len]; > + const u8 id[] = {0x01, 0x00, 0x06, 0x00}; > + u8 tmp[ARRAY_SIZE(id)]; > > - if (!via_aux_read(&drv, 0x00, tmp, len) || memcmp(id, tmp, len)) > + if (!via_aux_read(&drv, 0x00, tmp, sizeof(tmp)) || memcmp(id, tmp, sizeof(tmp))) > return; > > printk(KERN_INFO "viafb: Found %s at address 0x%x\n", name, addr); > > Cheers, > > Tycho >
On Fri, Mar 09, 2018 at 12:16:21AM -0600, Gustavo A. R. Silva wrote: > > I sent a patch for this six hours ago: > > https://patchwork.kernel.org/patch/10268591/ > > -- > Gustavo lol, I knew there would be a race on to fix these :) And you got it right, bonus points. Let's drop this one then. thanks, Tobin.
diff --git a/drivers/video/fbdev/via/via_aux_sii164.c b/drivers/video/fbdev/via/via_aux_sii164.c index ca1b35f033b1..87db6c98d680 100644 --- a/drivers/video/fbdev/via/via_aux_sii164.c +++ b/drivers/video/fbdev/via/via_aux_sii164.c @@ -35,10 +35,10 @@ static void probe(struct via_aux_bus *bus, u8 addr) .addr = addr, .name = name}; /* check vendor id and device id */ - const u8 id[] = {0x01, 0x00, 0x06, 0x00}, len = ARRAY_SIZE(id); - u8 tmp[len]; + const u8 id[] = {0x01, 0x00, 0x06, 0x00}; + u8 tmp[ARRAY_SIZE(id)]; - if (!via_aux_read(&drv, 0x00, tmp, len) || memcmp(id, tmp, len)) + if (!via_aux_read(&drv, 0x00, tmp, sizeof(tmp)) || memcmp(id, tmp, sizeof(tmp))) return; printk(KERN_INFO "viafb: Found %s at address 0x%x\n", name, addr);