diff options
| author | Federico Angelilli <code@fedang.net> | 2024-11-19 01:22:23 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-11-19 01:22:23 +0100 |
| commit | 2103b6b1c2d9d07e207bea3abde001efeede402d (patch) | |
| tree | f8888971f5a9100d38b10f72fb1d2a65a92c8fc0 /src/blocks/ram.c | |
| parent | 0d088e48b5e4480fe2421bb90d601131bed35c8a (diff) | |
Improve error reporting
Diffstat (limited to 'src/blocks/ram.c')
| -rw-r--r-- | src/blocks/ram.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/blocks/ram.c b/src/blocks/ram.c index 4841860..8790ee3 100644 --- a/src/blocks/ram.c +++ b/src/blocks/ram.c @@ -124,33 +124,33 @@ static void block_ram_clean(block_t *block) free(ram->block.text); } -static bool block_ram_validate(block_t *block, const block_scheme_t *scheme) +static int block_ram_validate(block_t *block, const block_scheme_t *scheme) { block_ram_t *ram = (block_ram_t *)block; + int errors = 0; if (ram->block.text == NULL) { log_error("Block '%s' requires key '%s'", block->label, "text"); - return false; + errors++; } if (!format_init(&ram->format, ram->block.text, '%')) { log_error("Block '%s' has an invalid format", block->label); - return false; - } - - int marked = format_remark(&ram->format, block->label, block_ram_options); - if (marked < 0) - return false; + errors++; + } else { + int marked = format_remark(&ram->format, block->label, block_ram_options); + if (marked < 0) + errors += -marked; - if (marked == 0) { - log_warn("Block '%s' does not use any ram option", block->label); + if (marked == 0) { + log_warn("Block '%s' does not use any ram option", block->label); - block->update_fn = NULL; - log_debug("Disabled updates for block '%s'", block->label); - return true; + block->update_fn = NULL; + log_debug("Disabled updates for block '%s'", block->label); + } } - return true; + return errors; } const block_scheme_t block_ram_scheme = { @@ -159,5 +159,4 @@ const block_scheme_t block_ram_scheme = { .alloc_fn = block_ram_alloc, .clean_fn = block_ram_clean, .validate_fn = block_ram_validate, - .resolve_fn = NULL, }; |
