drivers: modem: initialize variables to avoid warn

The variables 'first' and 'next' in function 'stats_buffer_list_first()'
and 'stats_buffer_list_next()' were potentially used uninitialized.

Depending on the compiler and target architecture, this can lead to
different behavior, including warnings or errors when using strict
warning flags.

By initializing these pointers to 'NULL', we ensure consistent and
expected behavior across all toolchains and configurations.

Signed-off-by: Fabian Kainka <kainka@cognid.de>
This commit is contained in:
Fabian Kainka 2024-11-15 10:56:25 +01:00 committed by Anas Nashif
parent 5f6fc8ad5d
commit c6b663e50b

View file

@ -32,7 +32,7 @@ static void stats_buffer_list_append(struct modem_stats_buffer *buffer)
static struct modem_stats_buffer *stats_buffer_list_first(void) static struct modem_stats_buffer *stats_buffer_list_first(void)
{ {
struct modem_stats_buffer *first; struct modem_stats_buffer *first = NULL;
K_SPINLOCK(&stats_buffer_lock) { K_SPINLOCK(&stats_buffer_lock) {
first = stats_buffer_from_node(sys_slist_peek_head(&stats_buffer_list)); first = stats_buffer_from_node(sys_slist_peek_head(&stats_buffer_list));
@ -43,7 +43,7 @@ static struct modem_stats_buffer *stats_buffer_list_first(void)
static struct modem_stats_buffer *stats_buffer_list_next(struct modem_stats_buffer *buffer) static struct modem_stats_buffer *stats_buffer_list_next(struct modem_stats_buffer *buffer)
{ {
struct modem_stats_buffer *next; struct modem_stats_buffer *next = NULL;
K_SPINLOCK(&stats_buffer_lock) { K_SPINLOCK(&stats_buffer_lock) {
next = stats_buffer_from_node(sys_slist_peek_next(&buffer->node)); next = stats_buffer_from_node(sys_slist_peek_next(&buffer->node));