Whamcloud - gitweb
LU-15220 tests: avoid gcc-11 -Werror=stringop-overread warning
authorJian Yu <yujian@whamcloud.com>
Mon, 24 Jan 2022 07:20:59 +0000 (23:20 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 25 Jan 2022 15:42:58 +0000 (15:42 +0000)
commitc3b93bf2fed9e4a5e6945d615b57045361612949
tree26c8452bd2823db9f2cee8a234f927588dddaa72
parent8ff6022c8759c85d3ab789863436064465c5c58d
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

Lustre-change: https://review.whamcloud.com/45777
Lustre-commit: TBD (from 300b310a3cc6b4591a8b98d7e93d363604983680)

Change-Id: I90b936835c6236a0f47e744013e3e480442f682c
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/46277
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/tests/badarea_io.c