Skip to content

Commit c6b663e

Browse files
ct-fknashif
authored andcommitted
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 <[email protected]>
1 parent 5f6fc8a commit c6b663e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

subsys/modem/modem_stats.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void stats_buffer_list_append(struct modem_stats_buffer *buffer)
3232

3333
static struct modem_stats_buffer *stats_buffer_list_first(void)
3434
{
35-
struct modem_stats_buffer *first;
35+
struct modem_stats_buffer *first = NULL;
3636

3737
K_SPINLOCK(&stats_buffer_lock) {
3838
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)
4343

4444
static struct modem_stats_buffer *stats_buffer_list_next(struct modem_stats_buffer *buffer)
4545
{
46-
struct modem_stats_buffer *next;
46+
struct modem_stats_buffer *next = NULL;
4747

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

0 commit comments

Comments
 (0)