From 5c1d19ad0204d2eeacda6dea36cffd7a4f2b9585 Mon Sep 17 00:00:00 2001 From: "pedro.minatel" Date: Mon, 25 Jan 2021 09:37:23 +0000 Subject: [PATCH 1/2] example/storage: fix find_partition function when no partition is found --- examples/storage/partition_api/partition_find/main/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/storage/partition_api/partition_find/main/main.c b/examples/storage/partition_api/partition_find/main/main.c index 4b29ef99cd..392f3f3ab6 100644 --- a/examples/storage/partition_api/partition_find/main/main.c +++ b/examples/storage/partition_api/partition_find/main/main.c @@ -47,8 +47,14 @@ static void find_partition(esp_partition_type_t type, esp_partition_subtype_t su { ESP_LOGI(TAG, "Find partition with type %s, subtype %s, label %s...", get_type_str(type), get_subtype_str(subtype), name == NULL ? "NULL (unspecified)" : name); + const esp_partition_t * part = esp_partition_find_first(type, subtype, name); - ESP_LOGI(TAG, "\tfound partition '%s' at offset 0x%x with size 0x%x", part->label, part->address, part->size); + + if(part != NULL) { + ESP_LOGI(TAG, "\tfound partition '%s' at offset 0x%x with size 0x%x", part->label, part->address, part->size); + } else { + ESP_LOGE(TAG, "\tpartition not found!"); + } } void app_main(void) From 42b85a82aebbe8f20cd79ab536c8deb62c648f69 Mon Sep 17 00:00:00 2001 From: Pedro Minatel Date: Mon, 25 Jan 2021 20:11:06 +0800 Subject: [PATCH 2/2] Apply 1 suggestion(s) to 1 file(s) --- examples/storage/partition_api/partition_find/main/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/storage/partition_api/partition_find/main/main.c b/examples/storage/partition_api/partition_find/main/main.c index 392f3f3ab6..d14aab6da1 100644 --- a/examples/storage/partition_api/partition_find/main/main.c +++ b/examples/storage/partition_api/partition_find/main/main.c @@ -50,7 +50,7 @@ static void find_partition(esp_partition_type_t type, esp_partition_subtype_t su const esp_partition_t * part = esp_partition_find_first(type, subtype, name); - if(part != NULL) { + if (part != NULL) { ESP_LOGI(TAG, "\tfound partition '%s' at offset 0x%x with size 0x%x", part->label, part->address, part->size); } else { ESP_LOGE(TAG, "\tpartition not found!");