[Virtio-fs] [PATCH] virtiofsd: Fix side-effect in assert()
Philippe Mathieu-Daudé
philmd at redhat.com
Fri Apr 9 10:23:31 UTC 2021
On 4/9/21 12:06 PM, Greg Kurz wrote:
> 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>
> ---
> tools/virtiofsd/passthrough_ll.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd at redhat.com>
More information about the Virtio-fs
mailing list