Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arcnet: Make a char * array const char * const

Might as well be specific about the use of this array.

Add a commment questioning the indexing too.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

authored by

Joe Perches and committed by
Michael Grzeschik
4e299b92 26c6d281

+10 -5
+10 -5
drivers/net/arcnet/com20020.c
··· 42 42 #include "arcdevice.h" 43 43 #include "com20020.h" 44 44 45 - static char *clockrates[] = { 46 - "XXXXXXX", "XXXXXXXX", "XXXXXX", 47 - "2.5 Mb/s", "1.25Mb/s", "625 Kb/s", "312.5 Kb/s", 48 - "156.25 Kb/s", "Reserved", "Reserved", "Reserved" 45 + static const char * const clockrates[] = { 46 + "XXXXXXX", "XXXXXXXX", "XXXXXX", "2.5 Mb/s", 47 + "1.25Mb/s", "625 Kb/s", "312.5 Kb/s", "156.25 Kb/s", 48 + "Reserved", "Reserved", "Reserved" 49 49 }; 50 50 51 51 static void com20020_command(struct net_device *dev, int command); ··· 234 234 235 235 arc_printk(D_NORMAL, dev, "Using CKP %d - data rate %s\n", 236 236 lp->setup >> 1, 237 - clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]); 237 + clockrates[3 - 238 + ((lp->setup2 & 0xF0) >> 4) + 239 + ((lp->setup & 0x0F) >> 1)]); 240 + /* The clockrates array index looks very fragile. 241 + * It seems like it could have negative indexing. 242 + */ 238 243 239 244 if (register_netdev(dev)) { 240 245 free_irq(dev->irq, dev);