seq_file: fix NULL pointer arithmetic warning
authorMaíra Canal <maira.canal@usp.br>
Mon, 31 Jan 2022 18:22:42 +0000 (15:22 -0300)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 1 Feb 2022 16:31:55 +0000 (11:31 -0500)
commit90b2433edb6d995bd23d6adde753095b4ab26104
tree808609b1f7efc50d00639b0b0754008f821c1274
parent6692531df62d812de5d22c8bca0d90edc163aa84
seq_file: fix NULL pointer arithmetic warning

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@usp.br>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/kernfs/file.c
fs/seq_file.c
include/linux/seq_file.h