Re: [PATCH] hfs/hfsplus: use WARN_ON for sanity check

From: Christian Brauner
Date: Tue Mar 23 2021 - 05:01:43 EST


On Mon, Mar 22, 2021 at 11:32:40PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> gcc warns about a couple of instances in which a sanity check
> exists but the author wasn't sure how to react to it failing,
> which makes it look like a possible bug:
>
> fs/hfsplus/inode.c: In function 'hfsplus_cat_read_inode':
> fs/hfsplus/inode.c:503:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 503 | /* panic? */;
> | ^
> fs/hfsplus/inode.c:524:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 524 | /* panic? */;
> | ^
> fs/hfsplus/inode.c: In function 'hfsplus_cat_write_inode':
> fs/hfsplus/inode.c:582:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 582 | /* panic? */;
> | ^
> fs/hfsplus/inode.c:608:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 608 | /* panic? */;
> | ^
> fs/hfs/inode.c: In function 'hfs_write_inode':
> fs/hfs/inode.c:464:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 464 | /* panic? */;
> | ^
> fs/hfs/inode.c:485:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
> 485 | /* panic? */;
> | ^
>
> panic() is probably not the correct choice here, but a WARN_ON
> seems appropriate and avoids the compile-time warning.
>
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> ---

Thanks!
Reviewed-by: Christian Brauner <christian.brauner@xxxxxxxxxx>