Commit c6b663e5 authored by Fabian Kainka's avatar Fabian Kainka Committed by Anas Nashif
Browse files

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: default avatarFabian Kainka <kainka@cognid.de>
parent 5f6fc8ad
Loading
Loading
Loading
Loading
+2 −2
Changes for subsys/modem/modem_stats.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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)
{
	struct modem_stats_buffer *first;
	struct modem_stats_buffer *first = NULL;

	K_SPINLOCK(&stats_buffer_lock) {
		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)
{
	struct modem_stats_buffer *next;
	struct modem_stats_buffer *next = NULL;

	K_SPINLOCK(&stats_buffer_lock) {
		next = stats_buffer_from_node(sys_slist_peek_next(&buffer->node));