Whamcloud - gitweb
LU-16980 build: fix gcc-12 [-Werror=use-after-free] error
authorJian Yu <yujian@whamcloud.com>
Mon, 31 Jul 2023 20:20:21 +0000 (13:20 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 1 Aug 2023 22:03:43 +0000 (22:03 +0000)
commitfbcb200628981f0cf01114c2016d2ebfbe575b28
treed64fb2bcc4b2d5b5800005c14c05d0bb295a67d2
parent2f9d52f76e95506233e62966aa9ce05f3ecbfb3d
LU-16980 build: fix gcc-12 [-Werror=use-after-free] error

This patch fixes the following [-Werror=use-after-free] and
[-Werror=stringop-overflow=] errors detected by gcc 12:

libcfs/include/libcfs/util/list.h:481:42: error: pointer 'tmp'
used after 'free' [-Werror=use-after-free]
  481 |              pos = list_entry(pos->member.next, typeof(*pos), member),  \
      |                                          ^
libcfs/include/libcfs/util/list.h:239:28: note: in definition of macro 'list_entry'
  239 |         ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
      |                            ^~~
obd.c:5118:9: note: in expansion of macro 'list_for_each_entry'
 5118 |         list_for_each_entry(tmp, head, lpn_list) {
      |         ^~~~~~~~~~~~~~~~~~~
obd.c:5124:17: note: call to 'free' here
 5124 |                 free(tmp);
      |                 ^~~~~~~~~

test_brw.c: In function 'main':
test_brw.c:227:22: error: 'write' specified size between 9223372036854775808
and 18446744073709551615 exceeds maximum object size 9223372036854775807
[-Werror=stringop-overflow=]
  227 |                 rc = write(fd, buf, len);
      |                      ^~~~~~~~~~~~~~~~~~~

Lustre-change: https://review.whamcloud.com/51819
Lustre-commit: TBD (from 8fa48300347ac3c7dffb361d1686c434127fe3e1)

Change-Id: Ibe783ab0d13e2ecde1736946323932ab5db53740
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51825
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/test_brw.c
lustre/utils/obd.c