diff options
Diffstat (limited to 'man/journal-iterate-foreach.c')
-rw-r--r-- | man/journal-iterate-foreach.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/man/journal-iterate-foreach.c b/man/journal-iterate-foreach.c index 381b50f..9c0fa0e 100644 --- a/man/journal-iterate-foreach.c +++ b/man/journal-iterate-foreach.c @@ -7,10 +7,10 @@ int main(int argc, char *argv[]) { int r; sd_journal *j; + r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); if (r < 0) { - errno = -r; - fprintf(stderr, "Failed to open journal: %m\n"); + fprintf(stderr, "Failed to open journal: %s\n", strerror(-r)); return 1; } SD_JOURNAL_FOREACH(j) { @@ -19,8 +19,7 @@ int main(int argc, char *argv[]) { r = sd_journal_get_data(j, "MESSAGE", (const void **)&d, &l); if (r < 0) { - errno = -r; - fprintf(stderr, "Failed to read message field: %m\n"); + fprintf(stderr, "Failed to read message field: %s\n", strerror(-r)); continue; } |