From 5affc221f3074be4e7239ba2a0683cae06b525fd Mon Sep 17 00:00:00 2001 From: Alexander Goncharov Date: Tue, 14 Feb 2023 19:31:44 +0400 Subject: flashrom: rewrite flashbuses_to_text() The previous implementation had no error handling, as a result the flashrom could crash if the computer ran out of memory. The new version returns NULL in such cases. Also, rewrite lots of `if` conditions to one cycle, store a name of buses and `enum chipbustype` in an array by using a custom struct. The caller always expected a non-null value, so change its behavior to handle a possible null value or use the `?` symbol. As far as `free()` can handle null pointers, do nothing with such callers. TEST=ninja test Change-Id: I59b9044c99b4ba6c00d8c97f1e91af09d70dce2c Signed-off-by: Alexander Goncharov Ticket: https://ticket.coreboot.org/issues/408 Reviewed-on: https://review.coreboot.org/c/flashrom/+/73039 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk --- print_wiki.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'print_wiki.c') diff --git a/print_wiki.c b/print_wiki.c index 2c8c10934..a0cade9c1 100644 --- a/print_wiki.c +++ b/print_wiki.c @@ -325,7 +325,7 @@ static void print_supported_chips_wiki(int cols) "|| %s || {{%s}} || {{%s}} || {{%s}} || {{%s}}" "|| %s || %s\n", (c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name, - f->total_size, s, + f->total_size, s ? s : "?", test_state_to_template(f->tested.probe), test_state_to_template(f->tested.read), test_state_to_template(f->tested.erase), -- cgit v1.2.3