From: Yu Watanabe Date: Tue, 23 Jun 2026 15:32:16 +0000 (+0900) Subject: journal-importer: avoid false maybe-uninitialized warning X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee6522d0362e5656d898b4122ef8a6a0b0ee9e5e;p=thirdparty%2Fsystemd.git journal-importer: avoid false maybe-uninitialized warning Observerd on Ubuntu 24.04 with GCC 13 on arm64 architecture. ``` ../src/shared/journal-importer.c: In function ‘journal_importer_process_data’: ../src/shared/journal-importer.c:344:30: error: ‘line’ may be used uninitialized [-Werror=maybe-uninitialized] 344 | if (!journal_field_valid(line, n - 1, true)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/journal-importer.c:295:23: note: ‘line’ was declared here 295 | char *line, *sep; | ^~~~ cc1: all warnings being treated as errors ``` --- diff --git a/src/shared/journal-importer.c b/src/shared/journal-importer.c index 471ad879a4d..128866e17c5 100644 --- a/src/shared/journal-importer.c +++ b/src/shared/journal-importer.c @@ -292,7 +292,7 @@ int journal_importer_process_data(JournalImporter *imp) { switch (imp->state) { case IMPORTER_STATE_LINE: { - char *line, *sep; + char *line = NULL; /* avoid false maybe-uninitialized warning */ size_t n = 0; assert(imp->data_size == 0); @@ -317,7 +317,7 @@ int journal_importer_process_data(JournalImporter *imp) { COREDUMP\n LLLLLLLL0011223344...\n */ - sep = memchr(line, '=', n); + char *sep = memchr(line, '=', n); if (sep) { /* chomp newline */ n--;