Skip to contentSkip to conversation

drivers/char: Use ARRAY_SIZE macro

PATCH Andrew Morton 3 participants 4 messages Nov 17, 2005 – Nov 21, 2005 Kernel janitors

lore
Share & tools
lore
#0 lore raw
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

#1 lore raw
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

#3 lore raw
In reply to Andrew Morton
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.c seems 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