[warnings][gcc 11] Fix a few annoying out of bounds pointer warnings
It seems to be in the case of a string op against a raw address, the compiler decides the destination object is 0 bytes long and throws a particular warning. Work around it by not using memcpy in one case and by disabling the warning in the other. Both are fairly benign code that basically operates in a hard coded way that knows the destination buffer is valid.
This commit is contained in:
@@ -21,9 +21,9 @@
|
|||||||
#include <lk/console_cmd.h>
|
#include <lk/console_cmd.h>
|
||||||
|
|
||||||
#if defined(SDRAM_BASE)
|
#if defined(SDRAM_BASE)
|
||||||
#define DOWNLOAD_BASE ((void*)SDRAM_BASE)
|
#define DOWNLOAD_BASE ((unsigned char*)SDRAM_BASE)
|
||||||
#else
|
#else
|
||||||
#define DOWNLOAD_BASE ((void*)0)
|
#define DOWNLOAD_BASE ((unsigned char*)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FNAME_SIZE 64
|
#define FNAME_SIZE 64
|
||||||
@@ -49,11 +49,11 @@ static download_t *make_download(const char *name) {
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_ram_zone(download_t *d, int slot) {
|
static void set_ram_zone(download_t *d, unsigned char *spot, int slot) {
|
||||||
d->start = DOWNLOAD_BASE + (DOWNLOAD_SLOT_SIZE * slot);
|
d->start = spot + (DOWNLOAD_SLOT_SIZE * slot);
|
||||||
d->end = d->start;
|
d->end = d->start;
|
||||||
d->max = d->end + DOWNLOAD_SLOT_SIZE;
|
d->max = d->end + DOWNLOAD_SLOT_SIZE;
|
||||||
memset(d->start, 0, DOWNLOAD_SLOT_SIZE);
|
memset(spot, 0, DOWNLOAD_SLOT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t output_result(const download_t *download) {
|
static size_t output_result(const download_t *download) {
|
||||||
@@ -165,7 +165,7 @@ usage:
|
|||||||
slot = argv[3].i;
|
slot = argv[3].i;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_ram_zone(download, slot);
|
set_ram_zone(download, DOWNLOAD_BASE, slot);
|
||||||
tftp_set_write_client(download->name, &tftp_callback, download);
|
tftp_set_write_client(download->name, &tftp_callback, download);
|
||||||
printf("ready for %s over tftp (at %p)\n", argv[2].str, download->start);
|
printf("ready for %s over tftp (at %p)\n", argv[2].str, download->start);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ MODULE := $(LOCAL_DIR)
|
|||||||
MODULE_SRCS += \
|
MODULE_SRCS += \
|
||||||
$(LOCAL_DIR)/loader.c \
|
$(LOCAL_DIR)/loader.c \
|
||||||
|
|
||||||
|
# disable a few warnings in gcc 11 that some of this module's code trips over
|
||||||
|
MODULE_COMPILEFLAGS += -Wno-array-bounds -Wno-stringop-overflow
|
||||||
|
|
||||||
MODULE_DEPS := \
|
MODULE_DEPS := \
|
||||||
lib/cksum \
|
lib/cksum \
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ void swd_init(void) {
|
|||||||
writel(M0_SUB_RST, RESET_CTRL0);
|
writel(M0_SUB_RST, RESET_CTRL0);
|
||||||
writel(0x18000000, M0SUB_ZEROMAP);
|
writel(0x18000000, M0SUB_ZEROMAP);
|
||||||
writel(0xffffffff, 0x18004000);
|
writel(0xffffffff, 0x18004000);
|
||||||
memcpy((void *) 0x18000000, zero_bin, sizeof(zero_bin));
|
unsigned char *ptr = (unsigned char *)0x18000000;
|
||||||
|
for (size_t i = 0; i < sizeof(zero_bin); i++) {
|
||||||
|
ptr[i] = zero_bin[i];
|
||||||
|
}
|
||||||
DSB;
|
DSB;
|
||||||
writel(0, RESET_CTRL0);
|
writel(0, RESET_CTRL0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user