[Virtio-fs] [PATCH] virtiofsd: Fix side-effect in assert()

Alex Bennée alex.bennee at linaro.org
Fri Apr 9 14:56:36 UTC 2021


Greg Kurz <groug at kaod.org> writes:

> It is bad practice to put an expression with a side-effect in
> assert() because the side-effect won't happen if the code is
> compiled with -DNDEBUG.
>
> Use an intermediate variable. Consolidate this in an macro to
> have proper line numbers when the assertion is hit.
>
> virtiofsd: ../../tools/virtiofsd/passthrough_ll.c:2797: lo_getxattr:
>  Assertion `fchdir_res == 0' failed.
> Aborted
>
>   2796          /* fchdir should not fail here */
> =>2797          FCHDIR_NOFAIL(lo->proc_self_fd);
>   2798          ret = getxattr(procname, name, value, size);
>   2799          FCHDIR_NOFAIL(lo->root.fd);
>
> Fixes: bdfd66788349 ("virtiofsd: Fix xattr operations")
> Cc: misono.tomohiro at jp.fujitsu.com
> Signed-off-by: Greg Kurz <groug at kaod.org>

Reviewed-by: Alex Bennée <alex.bennee at linaro.org>

-- 
Alex Bennée





More information about the Virtio-fs mailing list