Skip to contentSkip to conversation

scripts/mod/sumversion.c: replace strtok() with strsep()

PATCH In review [email protected] 3 participants 4 messages Mar 5, 2005 – Mar 18, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 12/12 scripts/mod/sumversion.c: replace strtok() with strsep()

Replaces strtok() with strsep()

---

 kj-domen/scripts/mod/sumversion.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)
scripts/mod/sumversion.c renamed from scripts/mod/sumversion.c~strtok-scripts_mod_sumversion +3 -1
diff -puN scripts/mod/sumversion.c~strtok-scripts_mod_sumversion scripts/mod/sumversion.c
@@ -419,7 +419,9 @@ void get_src_version(const char *modname
 	*end = '\0';
 
 	md4_init(&md);
-	for (fname = strtok(sources, " "); fname; fname = strtok(NULL, " ")) {
+	while ((fname = strsep(&sources, " ")) != NULL) {
+		if (!*fname)
+			continue;
 		if (!parse_source_files(fname, &md))
 			goto release;
 	}

_

#1 lore raw
Quoted 2 lines · On Sat, Mar 05, 2005 at 04:35:45PM +0100, [email protected] wrote:

Replaces strtok() with strsep()

Why - does it increase portability?

Sam

#3 lore raw
Quoted 4 lines · Nicolas Kaiser

* Sam Ravnborg <[email protected]>:

Quoted 2 lines · On Sat, Mar 05, 2005 at 04:35:45PM +0100, [email protected] wrote:
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Replaces strtok() with strsep()

Why - does it increase portability?

"strtok() is not thread and SMP safe and strsep() should be
used instead"

http://janitor.kernelnewbies.org/docs/driver-howto.html#3.3.1

It does not matter in this particular file.
But applied for consistency (so it does not show up if you grep for it).

Sam