On Thu, May 27, 2021 at 5:15 PM Hyeonggon Yoo <42.hyeyoo@xxxxxxxxx> wrote: > > Hello, I was compiling kernel with make CC=clang-10 W=1 -s > > there are some places that compiler complains about > pointer arithmetic like below.it says it's undefined behavior. > > is it just OK to use UBs like this (I hope it's not), > or am I missing something? > > fs/kernfs/file.c:128:15: warning: performing pointer arithmetic on > a null pointer has undefined behavior [-Wnull-pointer-arithmetic] > return NULL + !*ppos; > > Hyeonggon, there is a patch series from Arnd Bergmann, a well-known kernel developer and janitor, hanging around here: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=warnings-5.10-2 It includes a patch to address this issue: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/commit/?h=warnings-5.10-2&id=cda293a8ee8a2bc763c33828cbc9ff21af987d45 The patch title and commit message indicates that this was submitted in multiple versions to the mailing list. You can find more on its progress on the mailing list here: https://lore.kernel.org/lkml/?q=seq_file%3A+fix+clang+warning+for+NULL+pointer+arithmetic It seems that it has not landed in linux-next yet, though: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=grep&q=seq_file%3A+fix+clang+warning+for+NULL+pointer+arithmetic The commit and discussion around it will give you much more technical details on the issue and its resolution. I hope this helps. Lukas _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies