Skip to contentSkip to conversation

strtok --> strsep in framebuffer drivers

PATCH In review René Scharfe 2 participants 2 messages Oct 21, 2001 – Oct 26, 2001 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 strtok --> strsep in framebuffer drivers

Hi,

here is a patch to eliminate all uses of strtok from the framebuffer drivers. This is another step towards a strtok-free kernel. ;-)

It applies cleanly against kernels 2.4.13-pre5 and, with a few offsets, 2.4.12-ac3.

This patch is a bit lengthy, but hopefully easy to verify. Err, and I did NOT test this thing. Maybe it doesn't even compile. That said, please take a look at it and consider applying. It's not as I could've made many mistakes after all (hi Rusty! :).

René

diff -ur linux-2.4.13-pre5/drivers/video/acornfb.c linux-2.4.13-pre5-rs/drivers/video/acornfb.c

drivers/video/acornfb.c +1 -1
@@ -1528,7 +1528,7 @@
 
 	acornfb_init_fbinfo();
 
-	for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
+	while (opt = strsep(&options, ",")) {
 		if (!*opt)
 			continue;
 

diff -ur linux-2.4.13-pre5/drivers/video/amifb.c
linux-2.4.13-pre5-rs/drivers/video/amifb.c

drivers/video/amifb.c +0 -1
@@ -1192,7 +1192,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, 

",")) {
+ while (this_opt = strsep(&options, ",")) {
if (!strcmp(this_opt, "inverse")) {
amifb_inverse = 1; fb_invert_cmaps();
diff -ur linux-2.4.13-pre5/drivers/video/aty/atyfb_base.c linux-2.4.13-pre5-rs/drivers/video/aty/atyfb_base.c
--- linux-2.4.13-pre5/drivers/video/aty/atyfb_base.c Fri Sep 14 01:04:43 2001
+++ linux-2.4.13-pre5-rs/drivers/video/aty/atyfb_base.c Sun Oct 21 12:34:56
2001
@@ -2521,8 +2521,7 @@

     if (!options || !*options)

return 0;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ while (this_opt = strsep(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ur linux-2.4.13-pre5/drivers/video/aty128fb.c linux-2.4.13-pre5-rs/drivers/video/aty128fb.c

drivers/video/aty128fb.c +1 -2
@@ -1613,8 +1613,7 @@
     if (!options || !*options)
 	return 0;
 
-    for (this_opt = strtok(options, ","); this_opt;
-	 this_opt = strtok(NULL, ",")) {
+    while (this_opt = strsep(&options, ",")) {
 	if (!strncmp(this_opt, "font:", 5)) {
 	    char *p;
 	    int i;

diff -ur linux-2.4.13-pre5/drivers/video/controlfb.c linux-2.4.13-pre5-rs/drivers/video/controlfb.c

drivers/video/controlfb.c +1 -2
@@ -1423,8 +1423,7 @@
 	if (!options || !*options)
 		return;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5)) {
 			char *p;
 			int i;

diff -ur linux-2.4.13-pre5/drivers/video/cyberfb.c linux-2.4.13-pre5-rs/drivers/video/cyberfb.c

drivers/video/cyberfb.c +1 -2
@@ -1022,8 +1022,7 @@
 		return 0;
 	}
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strcmp(this_opt, "inverse")) {
 			Cyberfb_inverse = 1;
 			fb_invert_cmaps();

diff -ur linux-2.4.13-pre5/drivers/video/fm2fb.c
linux-2.4.13-pre5-rs/drivers/video/fm2fb.c

drivers/video/fm2fb.c +1 -2
@@ -430,8 +430,7 @@
     if (!options || !*options)
 	return 0;
 
-    for (this_opt = strtok(options, ","); this_opt;
-	 this_opt = strtok(NULL, ",")) {
+    while (this_opt = strsep(&options, ",")) {
 	if (!strncmp(this_opt, "pal", 3))
 	    fm2fb_mode = FM2FB_MODE_PAL;
 	else if (!strncmp(this_opt, "ntsc", 4))

diff -ur linux-2.4.13-pre5/drivers/video/hgafb.c
linux-2.4.13-pre5-rs/drivers/video/hgafb.c

drivers/video/hgafb.c +1 -2
@@ -795,8 +795,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-			this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5))
 			strcpy(fb_info.fontname, this_opt+5);
 	}

diff -ur linux-2.4.13-pre5/drivers/video/igafb.c
linux-2.4.13-pre5-rs/drivers/video/igafb.c

drivers/video/igafb.c +1 -2
@@ -773,8 +773,7 @@
     if (!options || !*options)
         return 0;
 
-    for (this_opt = strtok(options, ","); this_opt;
-         this_opt = strtok(NULL, ",")) {
+    while (this_opt = strsep(&options, ",")) {
         if (!strncmp(this_opt, "font:", 5)) {
                 char *p;
                 int i;

diff -ur linux-2.4.13-pre5/drivers/video/imsttfb.c linux-2.4.13-pre5-rs/drivers/video/imsttfb.c

drivers/video/imsttfb.c +1 -2
@@ -1977,8 +1977,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5)) {
 			char *p;
 			int i;

diff -ur linux-2.4.13-pre5/drivers/video/macfb.c
linux-2.4.13-pre5-rs/drivers/video/macfb.c

drivers/video/macfb.c +1 -1
@@ -848,7 +848,7 @@
 	if (!options || !*options)
 		return;
 	
-	for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!*this_opt) continue;
 		
 		if (! strcmp(this_opt, "inverse"))

diff -ur linux-2.4.13-pre5/drivers/video/matrox/matroxfb_base.c linux-2.4.13-pre5-rs/drivers/video/matrox/matroxfb_base.c
--- linux-2.4.13-pre5/drivers/video/matrox/matroxfb_base.c Sun Sep 30
21:26:08 2001
+++ linux-2.4.13-pre5-rs/drivers/video/matrox/matroxfb_base.c Sun Oct 21
12:46:21 2001
@@ -2355,7 +2355,7 @@
if (!options || !*options)
return 0;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ while (this_opt = strsep(&options, ",")) {
if (!*this_opt) continue;

dprintk("matroxfb_setup: option %s\n", this_opt);
diff -ur linux-2.4.13-pre5/drivers/video/platinumfb.c linux-2.4.13-pre5-rs/drivers/video/platinumfb.c

drivers/video/platinumfb.c +1 -2
@@ -841,8 +841,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5)) {
 			char *p;
 			int i;

diff -ur linux-2.4.13-pre5/drivers/video/radeonfb.c linux-2.4.13-pre5-rs/drivers/video/radeonfb.c

drivers/video/radeonfb.c +1 -2
@@ -537,8 +537,7 @@
         if (!options || !*options)
                 return 0;
  
-        for (this_opt = strtok (options, ","); this_opt;
-             this_opt = strtok (NULL, ",")) {
+	while (this_opt = strsep (&options, ",")) {
                 if (!strncmp (this_opt, "font:", 5)) {
                         char *p;
                         int i;

diff -ur linux-2.4.13-pre5/drivers/video/retz3fb.c linux-2.4.13-pre5-rs/drivers/video/retz3fb.c

drivers/video/retz3fb.c +1 -2
@@ -1348,8 +1348,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")){
+	while (this_opt = strsep(&options, ",")) {
 		if (!strcmp(this_opt, "inverse")) {
 			z3fb_inverse = 1;
 			fb_invert_cmaps();

diff -ur linux-2.4.13-pre5/drivers/video/riva/fbdev.c linux-2.4.13-pre5-rs/drivers/video/riva/fbdev.c

drivers/video/riva/fbdev.c +1 -2
@@ -2045,8 +2045,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5)) {
 			char *p;
 			int i;

diff -ur linux-2.4.13-pre5/drivers/video/sa1100fb.c linux-2.4.13-pre5-rs/drivers/video/sa1100fb.c

drivers/video/sa1100fb.c +1 -2
@@ -2299,8 +2299,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 
 		if (!strncmp(this_opt, "bpp:", 4))
 			current_par.max_bpp =

diff -ur linux-2.4.13-pre5/drivers/video/sgivwfb.c linux-2.4.13-pre5-rs/drivers/video/sgivwfb.c

drivers/video/sgivwfb.c +1 -2
@@ -862,8 +862,7 @@
   if (!options || !*options)
     return 0;
 
-  for (this_opt = strtok(options, ","); this_opt;
-       this_opt = strtok(NULL, ",")) {
+  while (this_opt = strsep(&options, ",")) {
     if (!strncmp(this_opt, "font:", 5))
       strcpy(fb_info.fontname, this_opt+5);
   }

diff -ur linux-2.4.13-pre5/drivers/video/sis/sis_main.c linux-2.4.13-pre5-rs/drivers/video/sis/sis_main.c

drivers/video/sis/sis_main.c +1 -2
@@ -1726,8 +1726,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!*this_opt)
 			continue;
 

diff -ur linux-2.4.13-pre5/drivers/video/sstfb.c
linux-2.4.13-pre5-rs/drivers/video/sstfb.c

drivers/video/sstfb.c +1 -2
@@ -1697,8 +1697,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for(this_opt = strtok(options, ","); this_opt;
-	    this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!*this_opt) continue;
 
 		f_ddprintk("option %s\n", this_opt);

diff -ur linux-2.4.13-pre5/drivers/video/tdfxfb.c
linux-2.4.13-pre5-rs/drivers/video/tdfxfb.c

drivers/video/tdfxfb.c +1 -3
@@ -2086,9 +2086,7 @@
   if(!options || !*options)
     return;
 
-  for(this_opt = strtok(options, ","); 
-      this_opt;
-      this_opt = strtok(NULL, ",")) {
+  while(this_opt = strsep(&options, ",")) {
     if(!strcmp(this_opt, "inverse")) {
       inverse = 1;
       fb_invert_cmaps();

diff -ur linux-2.4.13-pre5/drivers/video/tgafb.c
linux-2.4.13-pre5-rs/drivers/video/tgafb.c

drivers/video/tgafb.c +1 -1
@@ -889,7 +889,7 @@
     int i;
     
     if (options && *options) {
-    	for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+    	while (this_opt = strsep(&options, ",")) {
        	    if (!*this_opt) { continue; }
         
 	    if (!strncmp(this_opt, "font:", 5)) {

diff -ur linux-2.4.13-pre5/drivers/video/valkyriefb.c linux-2.4.13-pre5-rs/drivers/video/valkyriefb.c

drivers/video/valkyriefb.c +1 -2
@@ -801,8 +801,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt;
-	     this_opt = strtok(NULL, ",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!strncmp(this_opt, "font:", 5)) {
 			char *p;
 			int i;

diff -ur linux-2.4.13-pre5/drivers/video/vesafb.c
linux-2.4.13-pre5-rs/drivers/video/vesafb.c

drivers/video/vesafb.c +1 -1
@@ -457,7 +457,7 @@
 	if (!options || !*options)
 		return 0;
 	
-	for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!*this_opt) continue;
 		
 		if (! strcmp(this_opt, "inverse"))

diff -ur linux-2.4.13-pre5/drivers/video/vfb.c
linux-2.4.13-pre5-rs/drivers/video/vfb.c

drivers/video/vfb.c +1 -2
@@ -382,8 +382,7 @@
     if (!options || !*options)
 	return 0;
 
-    for (this_opt = strtok(options, ","); this_opt;
-	 this_opt = strtok(NULL, ",")) {
+    while (this_opt = strsep(&options, ",")) {
 	if (!strncmp(this_opt, "font:", 5))
 	    strcpy(fb_info.fontname, this_opt+5);
     }

diff -ur linux-2.4.13-pre5/drivers/video/vga16fb.c linux-2.4.13-pre5-rs/drivers/video/vga16fb.c

drivers/video/vga16fb.c +1 -1
@@ -692,7 +692,7 @@
 	if (!options || !*options)
 		return 0;
 	
-	for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+	while (this_opt = strsep(&options, ",")) {
 		if (!*this_opt) continue;
 		
 		if (!strncmp(this_opt, "font:", 5))

diff -ur linux-2.4.13-pre5/drivers/video/virgefb.c linux-2.4.13-pre5-rs/drivers/video/virgefb.c

drivers/video/virgefb.c +0 -1
@@ -1085,7 +1085,7 @@
 	if (!options || !*options)
 		return 0;
 
-	for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, 

","))
+ while (this_opt = strsep(&options, ",")) {
if (!strcmp(this_opt, "inverse")) {
Cyberfb_inverse = 1; fb_invert_cmaps();

#1 lore raw

Hi,

Quoted 13 lines

diff -ur linux-2.4.13-pre5/drivers/video/virgefb.c linux-2.4.13-pre5-rs/drivers/video/virgefb.c

drivers/video/virgefb.c Sun Oct 21 13:02:11 2001 renamed from drivers/video/virgefb.c Fri Sep 14 01:04:43 2001 +1 -1
@@ -1085,7 +1085,7 @@
        if (!options || !*options)
                return 0;
 
-       for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL,
 ","))
+       while (this_opt = strsep(&options, ",")) {
                if (!strcmp(this_opt, "inverse")) {
                        Cyberfb_inverse = 1;
Quoted 1 line
                        fb_invert_cmaps();

You add a left brace here.

bye, Roman