drivers/char: Use ARRAY_SIZE macro
Quoted 7 lines · Tobias Klauser
(quoted diff) +0
-2@@ -913,15 +913,10 @@ static int stl_parsebrd(stlconf_t *confp for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stl_brdstr) / sizeof(stlbrdtype_t); - for (i = 0; (i < nrbrdnames); i++) {
Review static int stl_parsebrd(stlconf_t *confp · line 921
Quoted 10 lines
(quoted diff) +1
-4+ for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) { if (strcmp(stl_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { - printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); - } confp->brdtype = stl_brdstr[i].type;
The second change here in stallion.c seems wrong.
I replaced it with
if (i == ARRAY_SIZE(stl_brdstr)) {
printk("STALLION: unknown board name, %s?\n", argp[0]);
return 0;
}_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 7 lines · Tobias Klauser
(quoted diff) +0
-2@@ -979,15 +977,10 @@ static int stli_parsebrd(stlconf_t *conf for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stli_brdstr) / sizeof(stlibrdtype_t); - for (i = 0; (i < nrbrdnames); i++) {
Review static int stli_parsebrd(stlconf_t *conf · line 985
Quoted 10 lines
(quoted diff) +1
-4+ for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) { if (strcmp(stli_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { - printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); - } confp->brdtype = stli_brdstr[i].type;
Same problem here.
if (i == ARRAY_SIZE(stli_brdstr)) {
printk("STALLION: unknown board name, %s?\n", argp[0]);
return 0;
}_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 8 lines · Andrew Morton
The second change here in
stallion.cseems wrong.I replaced it with
if (i == ARRAY_SIZE(stl_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); return 0; }
Oh sure! Don't know what hit me there. :-/ Thanks for correcting.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 21 lines · Andrew Morton
Quoted 7 lines · Tobias Klauser
(quoted diff) +0
-2@@ -913,15 +913,10 @@ static int stl_parsebrd(stlconf_t *confp for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); - nrbrdnames = sizeof(stl_brdstr) / sizeof(stlbrdtype_t); - for (i = 0; (i < nrbrdnames); i++) {Review static int stl_parsebrd(stlconf_t *confp · line 921
Quoted 10 lines
(quoted diff) +1
-4+ for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) { if (strcmp(stl_brdstr[i].name, argp[0]) == 0) break; } - if (i >= nrbrdnames) { - printk("STALLION: unknown board name, %s?\n", argp[0]); - return(0); - } confp->brdtype = stl_brdstr[i].type;The second change here in
stallion.cseems wrong.
Quoted 6 lines
I replaced it with
if (i == ARRAY_SIZE(stl_brdstr)) { printk("STALLION: unknown board name, %s?\n", argp[0]); return 0; }
Should correct KERN_* constant be used here in printk(); ?
- Christophe ([email protected])
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors