The coverity runs had a false positive complaining that save_ptr
is uninitialized in the call to strtok_r.
We could initialize it, but Zach points out that just using
strsep is a lot simpler if there's only one delimiter,
so just switch to that.
Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---
V2: Remove accidentally-added debug printfs, thanks Geoffredo!
diff --git a/cmds-balance.c b/cmds-balance.c
index b671e1d..cfbb8eb 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -67,11 +67,8 @@ static int parse_one_profile(const char *profile, u64 *flags)
static int parse_profiles(char *profiles, u64 *flags)
{
char *this_char;
- char *save_ptr;
- for (this_char = strtok_r(profiles, "|", &save_ptr);
- this_char != NULL;
- this_char = strtok_r(NULL, "|", &save_ptr)) {
+ while ((this_char = strsep(&profiles, "|"))) {
if (parse_one_profile(this_char, flags))
return 1;
}
@@ -136,14 +133,11 @@ static int parse_filters(char *filters, struct btrfs_balance_args *args)
{
char *this_char;
char *value;
- char *save_ptr;
if (!filters)
return 0;
- for (this_char = strtok_r(filters, ",", &save_ptr);
- this_char != NULL;
- this_char = strtok_r(NULL, ",", &save_ptr)) {
+ while ((this_char = strsep(&filters , ","))) {
if ((value = strchr(this_char, '=')) != NULL)
*value++ = 0;
if (!strcmp(this_char, "profiles")) {
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html