From f42b91fe46789c46445ba2841c31a9fa1f354ca0 Mon Sep 17 00:00:00 2001 From: Anton Maklakov Date: Thu, 24 May 2018 19:32:34 +0800 Subject: [PATCH] spi_flash: fix errors for GCC 8 support components/spi_flash/partition.c: In function 'load_partitions': components/spi_flash/partition.c:179:66: error: argument to 'sizeof' in 'strncpy' call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess] strncpy(item->info.label, (const char*) it->label, sizeof(it->label)); ^ --- components/bootloader_support/src/bootloader_common.c | 2 +- components/spi_flash/partition.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index 98e5606ed..12f60e9ce 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -134,7 +134,7 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat fl_ota_data_erase = true; } // partition->label is not null-terminated string. - strncpy(label, (char *)&partition->label, sizeof(partition->label)); + strncpy(label, (char *)&partition->label, sizeof(label) - 1); if (fl_ota_data_erase == true || (bootloader_common_label_search(list_erase, label) == true)) { err = esp_rom_spiflash_erase_area(partition->pos.offset, partition->pos.size); if (err != ESP_OK) { diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index 400329199..7f63d4c34 100644 --- a/components/spi_flash/partition.c +++ b/components/spi_flash/partition.c @@ -176,7 +176,7 @@ static esp_err_t load_partitions() } // it->label may not be zero-terminated - strncpy(item->info.label, (const char*) it->label, sizeof(it->label)); + strncpy(item->info.label, (const char*) it->label, sizeof(item->info.label) - 1); item->info.label[sizeof(it->label)] = 0; // add it to the list if (last == NULL) {