From: Karel Zak Date: Mon, 6 Dec 2010 23:08:11 +0000 (+0100) Subject: libmount: cleanup mangle() usage X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ac6a133276d200e1736853e58a05887e7f75e90;p=util-linux libmount: cleanup mangle() usage Signed-off-by: Karel Zak --- diff --git a/include/mangle.h b/include/mangle.h index 76d29bfa..158d0782 100644 --- a/include/mangle.h +++ b/include/mangle.h @@ -8,7 +8,7 @@ extern char *mangle(const char *s); extern void unmangle_to_buffer(const char *s, char *buf, size_t len); -extern char *unmangle(const char *s, const char **end); +extern char *unmangle(const char *s, char **end); static inline void unmangle_string(char *s) { diff --git a/lib/mangle.c b/lib/mangle.c index 398323a3..17ca8095 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -69,20 +69,20 @@ void unmangle_to_buffer(const char *s, char *buf, size_t len) *buf = '\0'; } -static inline const char *skip_nonspaces(const char *s) +static inline char *skip_nonspaces(const char *s) { while (*s && !(*s == ' ' || *s == '\t')) s++; - return s; + return (char *) s; } /* * Returns mallocated buffer or NULL in case of error. */ -char *unmangle(const char *s, const char **end) +char *unmangle(const char *s, char **end) { char *buf; - const char *e; + char *e; size_t sz; if (!s) diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c index 9e31d12f..a1e34db0 100644 --- a/mount/mount_mntent.c +++ b/mount/mount_mntent.c @@ -27,13 +27,6 @@ skip_spaces(char *s) { return s; } -static char * -skip_nonspaces(char *s) { - while (*s && !is_space_or_tab(*s)) - s++; - return s; -} - /* * fstat'ing the file and allocating a buffer holding all of it * may be a bad idea: if the file is /proc/mounts, the stat diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index 16fab89d..d7c27e65 100644 --- a/shlibs/mount/src/tab_parse.c +++ b/shlibs/mount/src/tab_parse.c @@ -182,40 +182,44 @@ static int mnt_parse_utab_line(mnt_fs *fs, const char *s) assert(!fs->target); while (p && *p) { + char *end = NULL; + while (*p == ' ') p++; if (!*p) break; if (!fs->source && !strncmp(p, "SRC=", 4)) { - char *v = unmangle(p + 4, &p); + char *v = unmangle(p + 4, &end); if (!v) goto enomem; if (strcmp(v, "none")) __mnt_fs_set_source_ptr(fs, v); } else if (!fs->target && !strncmp(p, "TARGET=", 7)) { - fs->target = unmangle(p + 7, &p); + fs->target = unmangle(p + 7, &end); if (!fs->target) goto enomem; } else if (!fs->root && !strncmp(p, "ROOT=", 5)) { - fs->root = unmangle(p + 5, &p); + fs->root = unmangle(p + 5, &end); if (!fs->root) goto enomem; } else if (!fs->bindsrc && !strncmp(p, "BINDSRC=", 8)) { - fs->bindsrc = unmangle(p + 8, &p); + fs->bindsrc = unmangle(p + 8, &end); if (!fs->bindsrc) goto enomem; } else if (!fs->optstr && !strncmp(p, "OPTS=", 5)) { - fs->optstr = unmangle(p + 5, &p); + fs->optstr = unmangle(p + 5, &end); if (!fs->optstr) goto enomem; } else { /* unknown variable */ while (*p && *p != ' ') p++; } + if (end) + p = end; } return 0;