summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-11-19 17:20:39 -0800
committerAndroid Code Review <code-review@android.com>2010-11-19 17:20:39 -0800
commit08da5c1f17afefe3c9f4f4d4456c5757dede62e1 (patch)
tree6b6043b005ffb9249b96dd0206a814b0453b92bc
parent09f774b7d3ad4e4205485b6997d44f7edd084598 (diff)
parent74ca25a716a060b4f676277262d112b569c5fbd2 (diff)
downloadvold-tools_r9.tar.gz
Merge "vold: replace strsep by strtok_r"tools_r9tools_r8froyo-plus-aosp
-rw-r--r--main.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/main.cpp b/main.cpp
index 530321c4..fbf12736 100644
--- a/main.cpp
+++ b/main.cpp
@@ -177,7 +177,8 @@ static int process_config(VolumeManager *vm) {
}
while(fgets(line, sizeof(line), fp)) {
- char *next = line;
+ const char *delim = " \t";
+ char *save_ptr;
char *type, *label, *mount_point;
n++;
@@ -186,24 +187,24 @@ static int process_config(VolumeManager *vm) {
if (line[0] == '#' || line[0] == '\0')
continue;
- if (!(type = strsep(&next, " \t"))) {
+ if (!(type = strtok_r(line, delim, &save_ptr))) {
SLOGE("Error parsing type");
goto out_syntax;
}
- if (!(label = strsep(&next, " \t"))) {
+ if (!(label = strtok_r(NULL, delim, &save_ptr))) {
SLOGE("Error parsing label");
goto out_syntax;
}
- if (!(mount_point = strsep(&next, " \t"))) {
+ if (!(mount_point = strtok_r(NULL, delim, &save_ptr))) {
SLOGE("Error parsing mount point");
goto out_syntax;
}
if (!strcmp(type, "dev_mount")) {
DirectVolume *dv = NULL;
- char *part, *sysfs_path;
+ char *part;
- if (!(part = strsep(&next, " \t"))) {
+ if (!(part = strtok_r(NULL, delim, &save_ptr))) {
SLOGE("Error parsing partition");
goto out_syntax;
}
@@ -218,7 +219,7 @@ static int process_config(VolumeManager *vm) {
dv = new DirectVolume(vm, label, mount_point, atoi(part));
}
- while((sysfs_path = strsep(&next, " \t"))) {
+ while (char *sysfs_path = strtok_r(NULL, delim, &save_ptr)) {
if (dv->addPath(sysfs_path)) {
SLOGE("Failed to add devpath %s to volume %s", sysfs_path,
label);