ACK: [PATCH] lib: fwts_coreboot_cbmem.c: clean up static analysis warning
Alex Hung
alex.hung at canonical.com
Thu Apr 29 00:49:18 UTC 2021
On 2021-04-28 4:16 p.m., Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Static analysis with clang scan-build is warning about cbmem_console_addr
> being not initialized and being passed to a map_memory call. Avoid this
> by explicitly initializing it to (off_t)-1 and checking for this not being
> changed in a for-loop rather than checking if the loop reached the end
> without breaking. This simplifies things for static analyzers.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_coreboot_cbmem.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_coreboot_cbmem.c b/src/lib/src/fwts_coreboot_cbmem.c
> index dd6d91eb..af0f1f5c 100644
> --- a/src/lib/src/fwts_coreboot_cbmem.c
> +++ b/src/lib/src/fwts_coreboot_cbmem.c
> @@ -305,7 +305,7 @@ static ssize_t memconsole_coreboot_read(
> char *fwts_coreboot_cbmem_console_dump(void)
> {
> unsigned int j;
> - off_t cbmem_console_addr;
> + off_t cbmem_console_addr = (off_t)-1;
> unsigned long long possible_base_addresses[] = { 0, 0xf0000 };
> struct cbmem_console *console_p;
> struct cbmem_console *console;
> @@ -317,7 +317,7 @@ char *fwts_coreboot_cbmem_console_dump(void)
> if (!parse_cbtable(possible_base_addresses[j], 0, &cbmem_console_addr))
> break;
> }
> - if (j == FWTS_ARRAY_SIZE(possible_base_addresses))
> + if (cbmem_console_addr == (off_t)-1)
> return NULL;
>
> console_p = map_memory(cbmem_console_addr, sizeof(*console_p));
>
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list