diff options
author | Maíra Canal <maira.canal@usp.br> | 2022-01-31 15:22:42 -0300 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2022-02-01 11:31:55 -0500 |
commit | 90b2433edb6d995bd23d6adde753095b4ab26104 (patch) | |
tree | 808609b1f7efc50d00639b0b0754008f821c1274 /fs/seq_file.c | |
parent | 6692531df62d812de5d22c8bca0d90edc163aa84 (diff) | |
download | linux-stable-90b2433edb6d995bd23d6adde753095b4ab26104.tar.gz linux-stable-90b2433edb6d995bd23d6adde753095b4ab26104.tar.bz2 linux-stable-90b2433edb6d995bd23d6adde753095b4ab26104.zip |
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>
Diffstat (limited to 'fs/seq_file.c')
-rw-r--r-- | fs/seq_file.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/seq_file.c b/fs/seq_file.c index f8e1f4ee87ff..7ab8a58c29b6 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -554,9 +554,9 @@ int seq_dentry(struct seq_file *m, struct dentry *dentry, const char *esc) } EXPORT_SYMBOL(seq_dentry); -static void *single_start(struct seq_file *p, loff_t *pos) +void *single_start(struct seq_file *p, loff_t *pos) { - return NULL + (*pos == 0); + return *pos ? NULL : SEQ_START_TOKEN; } static void *single_next(struct seq_file *p, void *v, loff_t *pos) |