From db2d5f385da6e07b395710735fa4a864c50f81b0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 23 Feb 2024 13:16:55 +0100 Subject: [PATCH 1/2] pkg/flashbd: assert presence of MTD device --- pkg/flashdb/mtd/fal_mtd_port.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/flashdb/mtd/fal_mtd_port.c b/pkg/flashdb/mtd/fal_mtd_port.c index 14e23ae825..248cf01859 100644 --- a/pkg/flashdb/mtd/fal_mtd_port.c +++ b/pkg/flashdb/mtd/fal_mtd_port.c @@ -74,6 +74,8 @@ struct fal_flash_dev mtd_flash0 = { void fdb_mtd_init(mtd_dev_t *mtd) { + assert(mtd); + unsigned sector_size; if (_mtd) { return; From 82aac9c761f02410fc0e743961cfea9d66b9ac05 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 23 Feb 2024 13:17:12 +0100 Subject: [PATCH 2/2] tests/pkg/flashdb_fal_cfg: abort test if no MTD device is configured --- tests/pkg/flashdb_fal_cfg/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/pkg/flashdb_fal_cfg/main.c b/tests/pkg/flashdb_fal_cfg/main.c index 1d7e2b3336..2f8eb2f46c 100644 --- a/tests/pkg/flashdb_fal_cfg/main.c +++ b/tests/pkg/flashdb_fal_cfg/main.c @@ -103,6 +103,11 @@ static fdb_time_t _get_time(void) int main(void) { + if (FDB_MTD == NULL) { + puts("No MTD device configured for test, abort."); + return -1; + } + int init_failed; fdb_mtd_init(FDB_MTD); size_t size = FDB_MTD->pages_per_sector * FDB_MTD->page_size;