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
```
This commit is contained in:
Yu Watanabe
2026-06-27 14:04:48 +09:00
parent d983d231eb
commit ee6522d036
+2 -2
View File
@@ -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--;