Re: [PATCH v3] seq_file: fix NULL pointer arithmetic warning

From: Matthew Wilcox
Date: Tue Feb 01 2022 - 11:30:31 EST


On Mon, Jan 31, 2022 at 03:22:42PM -0300, Maíra Canal wrote:
> Implement conditional logic in order to replace NULL pointer arithmetic.
>
> The use of NULL pointer arithmetic was pointed out by clang with the
> following warning:
>
> fs/kernfs/file.c:128:15: warning: performing pointer arithmetic on a
> null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> return NULL + !*ppos;
> ~~~~ ^
> fs/seq_file.c:559:14: warning: performing pointer arithmetic on a
> null pointer has undefined behavior [-Wnull-pointer-arithmetic]
> return NULL + (*pos == 0);
>
> Signed-off-by: Maíra Canal <maira.canal@xxxxxx>

Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>