FreeBSD: zfs_register_callbacks() must implement error check correctly
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Mon, 5 Dec 2022 18:16:50 +0000 (13:16 -0500)
committerGitHub <noreply@github.com>
Mon, 5 Dec 2022 18:16:50 +0000 (10:16 -0800)
commit7b9a423076f4da36b68009ced22259cd243166f6
tree3bca659ca8afdbf49e29c54345294a00aa953b5a
parentffd2e15d656e47f8d82ffbe46af1f0899ff889e5
FreeBSD: zfs_register_callbacks() must implement error check correctly

I read the following article and noticed a couple of ZFS bugs mentioned:

https://pvs-studio.com/en/blog/posts/cpp/0377/

I decided to search for them in the modern OpenZFS codebase and then
found one that matched the description of the first one:

V593 Consider reviewing the expression of the 'A = B != C' kind. The
expression is calculated as following: 'A = (B != C)'. zfs_vfsops.c 498

The consequence of this is that the error value is replaced with `1`
when there is an error. When there is no error, 0 is correctly passed.
This is a very minor issue that is unlikely to cause any real problems.

The incorrect error code would either be returned to the mount command
on a failure or any of `zfs receive`, `zfs recv`, `zfs rollback` or `zfs
upgrade`.

The second one has already been fixed.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14261
module/os/freebsd/zfs/zfs_vfsops.c