File: openbios-array-bounds-gcc12.patch

package info (click to toggle)
qemu 1%3A7.2%2Bdfsg-7%2Bdeb12u16
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-proposed-updates
  • size: 291,516 kB
  • sloc: ansic: 2,702,024; pascal: 112,708; python: 62,697; sh: 50,281; asm: 48,732; makefile: 17,260; cpp: 9,441; perl: 8,084; xml: 2,911; objc: 1,870; php: 1,299; tcl: 1,188; yacc: 604; lex: 363; sql: 71; awk: 35; sed: 11; javascript: 7
file content (25 lines) | stat: -rw-r--r-- 931 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Subject: openbios: do not error-out array-bounds warning
From: Michael Tokarev <mjt@tls.msk.ru>
Date: Fri, 02 Sep 2022 18:35:30 +0300

gcc-12.2 produces an apparently wrong warning for this file:

roms/openbios/arch/ppc/qemu/init.c:400:10: error: \
 array subscript 0 is outside array bounds of ‘uint32_t[0]’ {aka ‘unsigned int[]’} \
 [-Werror=array-bounds]
  400 |     *dsi = 0x48002002;
      |     =====^===========

Turn this particular -Werror back into warning. Gcc is apparently wrong here.

index e40385a70b..2e214aa079 100644
--- a/roms/openbios/arch/ppc/qemu/init.c
+++ b/roms/openbios/arch/ppc/qemu/init.c
@@ -397,4 +397,7 @@ ppc64_patch_handlers(void)
     uint32_t *isi = (uint32_t *)0x400UL;
 
+#pragma GCC diagnostic warning "-Warray-bounds"
+/* gcc-12 misreports array-bounds error in the following two assignments: */
+
     // Patch the first DSI handler instruction to: ba 0x2000
     *dsi = 0x48002002;