Commit 497b79d4 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Pavel Emelyanov

simplify the asprintf() failure handling in add_fsname_auto()

Contrary to what I naively thought, the contents of fsauto_names
is undefined if asprintf(&fsauto_names) and this was fixed by
a052e0b6 "check return code of asprintf".

But we can simplify this code a bit. If we rely on return value from
asprintf(), we can simply nullify fsauto_names on failure and avoid
the assymetrical "return false".
Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 161cb0b1
...@@ -1410,11 +1410,8 @@ bool add_fsname_auto(const char *names) ...@@ -1410,11 +1410,8 @@ bool add_fsname_auto(const char *names)
else if (!old) else if (!old)
fsauto_names = xstrdup(names); fsauto_names = xstrdup(names);
else { else {
fsauto_names = NULL; if (asprintf(&fsauto_names, "%s,%s", old, names) < 0)
if (asprintf(&fsauto_names, "%s,%s", old, names) < 0) { fsauto_names = NULL;
fsauto_names = old;
return false;
}
} }
xfree(old); xfree(old);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment