Fix to check if string is NULL or not
authorwchang kim <wchang.kim@samsung.com>
Fri, 30 Jun 2023 02:21:39 +0000 (11:21 +0900)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Mon, 12 Feb 2024 15:37:49 +0000 (16:37 +0100)
commitda63921df8cd2c9b38e4e3286c2ece1ac6384304
tree3a7c1dcb2ca8ca6c5c6eeffa58124c58674478e4
parent952657f0e3102bd1f7022e7edb763904cdb2ab36
Fix to check if string is NULL or not

An error occured while trying to build for riscv64 using gcc-13:
 > [  105s] In file included from ../src/nspawn/test-nspawn-tables.c:4:
 > [  105s] ../src/shared/test-tables.h: In function '_test_table.constprop':
 > [  105s] ../src/shared/test-tables.h:30:42: error: '%s' directive argument is null [-Werror=format-overflow=]
 > [  105s]    30 |                         printf("%s: %d → %s → %d\n", name, i, val, rev);
 > [  105s]       |                                          ^~
 > [  105s] ../src/shared/test-tables.h:30:42: error: '%s' directive argument is null [-Werror=format-overflow=]
 > [  105s] cc1: some warnings being treated as errors

The "val" can be NULL but the original code does not checking it, so the
compiler is complaining about it.

To fix this issue, ternary operator for val was used:
 > printf("%s: %d → %s → %d\n", name, i, val ? val : "(null)", rev);

Change-Id: I8f1b2b45d152ec362977154f62e333807392da76
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/shared/test-tables.h