]> git.ipfire.org Git - thirdparty/grub.git/commit
util/mkimage: Fix dangling pointer may be used error
authorMichael Chang <mchang@suse.com>
Mon, 28 Mar 2022 07:00:52 +0000 (15:00 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 20 Apr 2022 12:25:01 +0000 (14:25 +0200)
commitbe8eb0eed69f8bc9ac20837eae58e55218011880
tree6e18ec8ea46ad03475330eca45cf9f787b884b4f
parent9322a7740f7ca48d0b23a231af1c7807d9f7b5dd
util/mkimage: Fix dangling pointer may be used error

The warning is real as long as dangling pointer to tmp_ may be used if
o32 and o64 are both NULL. However that is not going to happen and can
be ignored safely because the PE_OHDR is being used in a context that
either o32 or o64 must have been properly initialized. Sadly compiler
seems not to always optimize that unused tmp_ away so explicit
suppression remain needed here.

  ../util/mkimage.c: In function 'grub_install_generate_image':
  ../util/mkimage.c:1422:41: error: dangling pointer to 'tmp_' may be used [-Werror=dangling-pointer=]
   1422 |         PE_OHDR (o32, o64, header_size) = grub_host_to_target32 (header_size);
  ../util/mkimage.c:857:28: note: 'tmp_' declared here
    857 |   __typeof__((o64)->field) tmp_;                \
        |                            ^~~~

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
util/mkimage.c