boot/platform/efi/arch/x86_64: fix -Warray-bounds

Size of gBootGDT[] is 'USER_DATA_SEGMENT + 1' defined at line 26,
and it equals USER_CODE_SEGMENT, so gBootGDT[USER_CODE_SEGMENT]
is out of bounds at line 44.

Change-Id: I1374f4d1185b6a47f910ac128d49a07cdd80d925
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4536
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Murai Takashi 2021-09-30 21:07:52 +09:00 committed by Jérôme Duval
parent 1496cfe1de
commit 2cc1b23d48

View File

@ -22,10 +22,6 @@
#include "efi_platform.h"
#undef BOOT_GDT_SEGMENT_COUNT
#define BOOT_GDT_SEGMENT_COUNT (USER_DATA_SEGMENT + 1)
extern uint64 gLongGDT;
extern uint64 gLongGDTR;
segment_descriptor gBootGDT[BOOT_GDT_SEGMENT_COUNT];
@ -34,6 +30,11 @@ segment_descriptor gBootGDT[BOOT_GDT_SEGMENT_COUNT];
static void
long_gdt_init()
{
STATIC_ASSERT(BOOT_GDT_SEGMENT_COUNT > KERNEL_CODE_SEGMENT
&& BOOT_GDT_SEGMENT_COUNT > KERNEL_DATA_SEGMENT
&& BOOT_GDT_SEGMENT_COUNT > USER_CODE_SEGMENT
&& BOOT_GDT_SEGMENT_COUNT > USER_DATA_SEGMENT);
clear_segment_descriptor(&gBootGDT[0]);
// Set up code/data segments (TSS segments set up later in the kernel).