strtok --> strsep (again)
Subsystems (15)
PATCH 1/1 strtok --> strsep (again)
Hi,
patch below replaces most uses of strtok by strsep. It compiles, but otherwise it's untested.
This change is suggested by the Kernel Janitor TODO List because strtok is not threadsafe. For most of the framebuffer drivers it was already done. For some more information see lib/string.c:14.
Linus, please apply.
René
drivers/isdn/avmb1/capifs.c | 7 +++---- drivers/scsi/ibmmca.c | 5 ++--- drivers/usb/inode.c | 6 +++--- drivers/video/atafb.c | 2 +- drivers/video/aty/atyfb_base.c | 2 ++ drivers/video/aty128fb.c | 4 +++- drivers/video/clgenfb.c | 3 +-- drivers/video/sis/sis_main.c | 3 +-- fs/adfs/super.c | 4 +++- fs/affs/super.c | 4 +++- fs/autofs/inode.c | 4 +++- fs/autofs4/inode.c | 4 +++- fs/devpts/inode.c | 7 +++---- fs/ext2/super.c | 6 +++--- fs/ext3/super.c | 6 +++--- fs/hfs/super.c | 5 +++-- fs/hpfs/super.c | 4 +++- fs/intermezzo/super.c | 6 +++--- fs/isofs/inode.c | 4 +++- fs/nfs/nfsroot.c | 6 +++--- fs/ntfs/fs.c | 5 ++++- fs/proc/inode.c | 4 +++- fs/reiserfs/super.c | 4 +++- fs/udf/super.c | 4 +++- fs/ufs/super.c | 7 +++---- mm/shmem.c | 7 +++---- 26 files changed, 71 insertions(+), 52 deletions(-)
drivers/isdn/avmb1/capifs.c +3 -4
@@ -232,10 +232,9 @@unsigned int maxncci =512 ;char *this_char, *value; - this_char =NULL ; -if ( options ) - this_char =strtok (options,"," ); -for ( ; this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"uid" )) {
drivers/scsi/ibmmca.c +2 -3
@@ -1406,9 +1406,9 @@ io_base =0 ; id_base =0 ;if (str) { - token =strtok (str,"," ); j =0 ; -while (token) { +while ((token =strsep (&str,"," )) !=NULL ) { +if (!*token)continue ;if (!strcmp (token,"activity" )) display_mode |=LED_ACTIVITY ;if (!strcmp (token,"display" )) display_mode |=LED_DISP ;if (!strcmp (token,"adisplay" )) display_mode |=LED_ADISP ;
@@ -1424,7 +1424,6 @@ scsi_id[id_base++] =simple_strtoul (token,NULL ,0 ); j++; } - token =strtok (NULL ,"," ); } }else if (ints) {for (i =0 ; i <IM_MAX_HOSTS &&2 *i+2 < ints[0 ]; i++) {
drivers/usb/inode.c +3 -3
@@ -65,9 +65,9 @@ {char *curopt =NULL , *value; -if (data) - curopt =strtok (data,"," ); -for (; curopt; curopt =strtok (NULL ,"," )) { +while ((curopt =strsep (&data,"," )) !=NULL ) { +if (!*curopt) +continue ;if ((value =strchr (curopt,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (curopt,"devuid" )) {
drivers/video/atafb.c +1 -1
@@ -2899,7 +2899,7 @@if (!options || !*options)return 0 ; -for (this_opt=strtok (options,"," ); this_opt; this_opt=strtok (NULL ,"," )) { +while ((this_opt=strsep (&options,"," )) !=NULL ) {if (!*this_opt)continue ;if ((temp=get_video_mode (this_opt))) default_par=temp;
drivers/video/aty/atyfb_base.c +2 -0
@@ -2522,6 +2522,8 @@return 0 ;while ((this_opt =strsep (&options,"," )) !=NULL ) { +if (!*this_opt) +continue ;if (!strncmp (this_opt,"font:" ,5 )) {char *p;int i;
drivers/video/aty128fb.c +3 -1
@@ -1620,7 +1620,9 @@if (!options || !*options)return 0 ; -while (this_opt =strsep (&options,"," )) { +while ((this_opt =strsep (&options,"," )) !=NULL ) { +if (!*this_opt) +continue ;if (!strncmp (this_opt,"font:" ,5 )) {char *p;int i;
drivers/video/clgenfb.c +1 -2
@@ -2840,8 +2840,7 @@if (!options || !*options)return 0 ; -for (this_opt =strtok (options,"," ); this_opt !=NULL ; - this_opt =strtok (NULL ,"," )) { +while ((this_opt =strsep (&options,"," )) !=NULL ) {if (!*this_opt)continue ;DPRINTK ("clgenfb_setup: option '%s'\n" , this_opt);
drivers/video/sis/sis_main.c +1 -2
@@ -2257,8 +2257,7 @@if (!options || !*options)return 0 ; -for (this_opt =strtok (options,"," ); this_opt; - this_opt =strtok (NULL ,"," )) { +while ((this_opt =strsep (&options,"," )) !=NULL ) {if (!*this_opt)continue ;
fs/adfs/super.c +3 -1
@@ -171,7 +171,9 @@if (!options)return 0 ; -for (opt =strtok (options,"," ); opt !=NULL ; opt =strtok (NULL ,"," )) { +while ((opt =strsep (&options,"," )) !=NULL ) { +if (!*opt) +continue ; value =strchr (opt,'=' );if (value) *value++ ='\0' ;
fs/affs/super.c +3 -1
@@ -109,7 +109,9 @@ *mount_opts =0 ;if (!options)return 1 ; -for (this_char =strtok (options,"," ); this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ; f =0 ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;
fs/autofs/inode.c +3 -1
@@ -61,7 +61,9 @@ *pipefd =-1 ;if ( !options )return 1 ; -for (this_char =strtok (options,"," ); this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*value) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"fd" )) {
fs/autofs4/inode.c +3 -1
@@ -112,7 +112,9 @@ *pipefd =-1 ;if ( !options )return 1 ; -for (this_char =strtok (options,"," ); this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"fd" )) {
fs/devpts/inode.c +3 -4
@@ -66,10 +66,9 @@umode_t mode =0600 ;char *this_char, *value; - this_char =NULL ; -if ( options ) - this_char =strtok (options,"," ); -for ( ; this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"uid" )) {
fs/ext2/super.c +3 -3
@@ -171,9 +171,9 @@if (!options)return 1 ; -for (this_char =strtok (options,"," ); - this_char !=NULL ; - this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"bsddf" ))
fs/ext3/super.c +3 -3
@@ -504,9 +504,9 @@if (!options)return 1 ; -for (this_char =strtok (options,"," ); - this_char !=NULL ; - this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"bsddf" ))
fs/hfs/super.c +3 -2
@@ -181,8 +181,9 @@if (!options) { goto done; } -for (this_char =strtok (options,"," ); this_char; - this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) { *value++ =0 ; }
fs/hpfs/super.c +3 -1
@@ -176,7 +176,9 @@/*printk("Parsing opts: '%s'\n",opts);*/ -for (p =strtok (opts,"," ); p !=0 ; p =strtok (0 ,"," )) { +while ((p =strsep (&opts,"," )) !=NULL ) { +if (!*p) +continue ;if ((rhs =strchr (p,'=' )) !=0 ) *rhs++ ='\0' ;if (!strcmp (p,"help" ))return 2 ;
fs/intermezzo/super.c +3 -3
@@ -120,10 +120,10 @@store_opt (prestodev,NULL ,PRESTO_PSDEV_NAME "0" );CDEBUG (D_SUPER ,"parsing options\n" ); -for (this_char =strtok (options,"," ); - this_char !=NULL ; - this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) {char *opt; +if (!*this_char) +continue ;CDEBUG (D_SUPER ,"this_char %s\n" , this_char);if ( (opt =read_opt ("fileset" , this_char)) ) {
fs/isofs/inode.c +3 -1
@@ -294,7 +294,9 @@ popt->session=-1 ; popt->sbsector=-1 ;if (!options)return 1 ; -for (this_char =strtok (options,"," ); this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if (strncmp (this_char,"norock" ,6 ) ==0 ) { popt->rock ='n' ;continue ;
fs/nfs/nfsroot.c +3 -3
@@ -202,8 +202,9 @@if ((options =strchr (name,',' ))) { *options++ =0 ; - cp =strtok (options,"," ); -while (cp) { +while ((cp =strsep (&options,"," )) !=NULL ) { +if (!*cp) +continue ;if ((val =strchr (cp,'=' ))) {struct nfs_int_opts *opts = root_int_opts; *val++ ='\0' ;
@@ -220,7 +221,6 @@ nfs_data.flags |= opts->or_mask; } } - cp =strtok (NULL ,"," ); } }if (name[0 ] &&strcmp (name,"default" )) {
fs/ntfs/fs.c +4 -1
@@ -361,10 +361,13 @@int use_utf8 =-1 ;/* If no NLS specified and loading the default NLS failed use utf8. */ int mft_zone_mul =-1 ;/* 1 */ +char *opts = opt;if (!opt) goto done; -for (opt =strtok (opt,"," ); opt; opt =strtok (NULL ,"," )) { +while ((opt =strsep (&opts,"," )) !=NULL ) { +if (!*opt) +continue ;if ((value =strchr (opt,'=' )) !=NULL ) *value ++='\0' ;if (strcmp (opt,"uid" ) ==0 ) {
fs/proc/inode.c +3 -1
@@ -106,7 +106,9 @@ *uid = current->uid; *gid = current->gid;if (!options)return 1 ; -for (this_char =strtok (options,"," ); this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"uid" )) {
fs/reiserfs/super.c +3 -1
@@ -154,7 +154,9 @@/* use default configuration: create tails, journaling on, no conversion to newest format */ return 1 ; -for (this_char =strtok (options,"," ); this_char !=NULL ; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"notail" )) {
fs/udf/super.c +3 -1
@@ -218,8 +218,10 @@if (!options)return 1 ; -for (opt =strtok (options,"," ); opt; opt =strtok (NULL ,"," )) +while ((opt =strsep (&options,"," )) !=NULL ) { +if (!*opt) +continue ;/* Make "opt=val" into two strings */ val =strchr (opt,'=' );if (val)
fs/ufs/super.c +3 -4
@@ -258,10 +258,9 @@if (!options)return 1 ; -for (this_char =strtok (options,"," ); - this_char !=NULL ; - this_char =strtok (NULL ,"," )) { - +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) *value++ =0 ;if (!strcmp (this_char,"ufstype" )) {
mm/shmem.c +3 -4
@@ -1197,10 +1197,9 @@ {char *this_char, *value, *rest; - this_char =NULL ; -if ( options ) - this_char =strtok (options,"," ); -for ( ; this_char; this_char =strtok (NULL ,"," )) { +while ((this_char =strsep (&options,"," )) !=NULL ) { +if (!*this_char) +continue ;if ((value =strchr (this_char,'=' )) !=NULL ) { *value++ =0 ; }else {