Whamcloud - gitweb
LU-15220 tests: avoid gcc-11 -Werror=stringop-overread warning 77/45777/7
authorJian Yu <yujian@whamcloud.com>
Thu, 20 Jan 2022 19:06:42 +0000 (11:06 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Jan 2022 05:17:08 +0000 (05:17 +0000)
commitc5fb44f5ecf8494cd5a497947981bd6905ddc084
tree338da0e990365acdc9a4343a6e2fac31043074f4
parentf71125e24c5dac88f4596b5ae93fe6f459ffacb0
LU-15220 tests: avoid gcc-11 -Werror=stringop-overread warning

GCC 11 warns about string and memory operations on fixed address:

In function 'memcpy', inlined from 'obd_uuid2str' at
lustre/include/uapi/linux/lustre/lustre_user.h:1222:3,
include/linux/fortify-string.h:20:33: error: '__builtin_memcpy'
reading 39 bytes from a region of size 0 [-Werror=stringop-overread]
   20 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
include/linux/fortify-string.h:191:16: note:
in expansion of macro '__underlying_memcpy'
  191 |         return __underlying_memcpy(p, q, size);
      |                ^~~~~~~~~~~~~~~~~~~

The patch avoids the above warning by not using a fixed address.

badarea_io.c:47:14: error: 'write' reading 5 bytes from a region
of size 0 [-Werror=stringop-overread]
   47 |         rc = write(fd, (void *)0x4096000, 5);
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The patch avoids the above warning by making the pointer volatile
as suggested in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16

Change-Id: I90b936835c6236a0f47e744013e3e480442f682c
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45777
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/tests/badarea_io.c