Hi Rong,
On Sat, 12 Nov 2022 13:01:04 +0800 Rong Tao rtoax@foxmail.com wrote:
Hi, Park, I just search on GCC source code, found GCC support "-Wstringop-overread" at least gcc-11.1.0, commit d14c547abd48("Add -Wstringop-overread for reading past the end by string functions.").
AND found a testsuite gcc/gcc/testsuite/gcc.dg/pragma-diag-10.c
10 #pragma GCC diagnostic push 11 #pragma GCC diagnostic ignored "-Wstringop-overflow" 12 #pragma GCC diagnostic ignored "-Wstringop-overread" 13 if (c != 0) 14 return __builtin_memchr (s, c, (unsigned long)-1); 15 #pragma GCC diagnostic pop
it's totally same as this PATCH.
I think the motivation for this patch is to eliminate the compilation warning, maybe one day we will compile the kernel with "-Werror -Wall", at which point this compilation warning will turn into a compilation error, and in case we already know it, we should fix this error in advance.
For old gcc, we can add this?
#pragma GCC diagnostic push +#if __GNUC__ >= 11 && __GNUC_MINOR__ >= 1 /* Ignore read(2) overflow and write(2) overread compile warnings */ #pragma GCC diagnostic ignored "-Wstringop-overread" #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif
What do you think?
I think it looks great! Looking forward to your v3 patch!
Thanks, SJ
Good day! Rong Tao