[CRIU] [PATCH 1/1] simplify the asprintf() failure handling in add_fsname_auto()
Tycho Andersen
tycho.andersen at canonical.com
Thu Apr 23 21:12:00 PDT 2015
On Thu, Apr 23, 2015 at 04:30:45PM +0200, Oleg Nesterov wrote:
> Contrary to what I naively thought, the contents of fsauto_names
> is undefined if asprintf(&fsauto_names) and this was fixed by
> a052e0b60a33e6c94e "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: Oleg Nesterov <oleg at redhat.com>
Whoops, sorry, just saw this. Looks good to me, I didn't check things
very closely, I just wanted it to build again :)
Acked-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
> mount.c | 7 ++-----
> 1 files changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/mount.c b/mount.c
> index 1d41d82..de2dcd7 100644
> --- a/mount.c
> +++ b/mount.c
> @@ -1410,11 +1410,8 @@ bool add_fsname_auto(const char *names)
> else if (!old)
> fsauto_names = xstrdup(names);
> else {
> - fsauto_names = NULL;
> - if (asprintf(&fsauto_names, "%s,%s", old, names) < 0) {
> - fsauto_names = old;
> - return false;
> - }
> + if (asprintf(&fsauto_names, "%s,%s", old, names) < 0)
> + fsauto_names = NULL;
> }
>
> xfree(old);
> --
> 1.5.5.1
>
>
More information about the CRIU
mailing list