diff options
Diffstat (limited to 'src/journald/instutil.c')
-rw-r--r-- | src/journald/instutil.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/journald/instutil.c b/src/journald/instutil.c index 44b7ddb..480751a 100644 --- a/src/journald/instutil.c +++ b/src/journald/instutil.c @@ -275,19 +275,21 @@ int match_journal_record(sd_journal *j, const char *message, const char *code_fu void ind_init() { + char errbuf[STRERROR_BUF_LEN]; + if (ind_journal == NULL) { sd_journal *journal; int r; r = sd_journal_open(&journal, 0); if (r < 0) { - error("ind_init(): Error opening journal: %s\n", strerror(-r)); + error("ind_init(): Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return; } r = sd_journal_seek_tail(journal); if (r < 0) { - error("ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r)); + error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); sd_journal_close(journal); return; } @@ -295,7 +297,7 @@ void ind_init() /* need to position the marker one step before EOF or otherwise the next sd_journal_next() call will overflow to the beginning */ r = sd_journal_previous(journal); if (r < 0) { - error("ind_init(): Error seeking to the end of the journal: %s\n", strerror(-r)); + error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); sd_journal_close(journal); return; } @@ -315,6 +317,7 @@ void ind_destroy() bool ind_watcher(void **data) { int r; + char errbuf[STRERROR_BUF_LEN]; if (ind_journal == NULL) { error("ind_watcher(): indications have not been initialized yet or error occurred previously\n"); @@ -332,7 +335,7 @@ bool ind_watcher(void **data) r = sd_journal_wait(ind_journal, (uint64_t) -1); } if (r < 0) { - warn("ind_watcher(): Error while waiting for new record: %s\n", strerror(-r)); + warn("ind_watcher(): Error while waiting for new record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return false; } if (r == SD_JOURNAL_INVALIDATE) { @@ -352,13 +355,14 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new int r; LMI_JournalLogRecord log_record; CMPIStatus st; + char errbuf[STRERROR_BUF_LEN]; g_return_val_if_fail(data != NULL, false); journal = data; r = sd_journal_next(journal); if (r < 0) { - error("ind_gather(): Failed to iterate to next entry: %s\n", strerror(-r)); + error("ind_gather(): Failed to iterate to next entry: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return false; } if (r == 0) { @@ -370,7 +374,7 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new LMI_JournalLogRecord_Init(&log_record, manager->broker, "root/cimv2"); r = create_LMI_JournalLogRecord(journal, &log_record, manager->broker); if (r <= 0) { - error("ind_gather(): Failed to create instance: %s\n", strerror(-r)); + error("ind_gather(): Failed to create instance: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return false; } @@ -431,13 +435,14 @@ journal_iter_new(const gchar *req_cursor, sd_journal **journal_out) char *cursor; sd_journal *journal; int r; + char errbuf[STRERROR_BUF_LEN]; if (journal_out) *journal_out = NULL; r = sd_journal_open(&journal, 0); if (r < 0) { - error("Error opening journal: %s\n", strerror(-r)); + error("Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return NULL; } @@ -447,21 +452,21 @@ journal_iter_new(const gchar *req_cursor, sd_journal **journal_out) r = sd_journal_seek_head(journal); if (r < 0) { - error("Error seeking to the requested journal position: %s\n", strerror(-r)); + error("Error seeking to the requested journal position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); sd_journal_close(journal); return NULL; } r = sd_journal_next(journal); if (r < 0) { - error("Error stepping next in the journal: %s\n", strerror(-r)); + error("Error stepping next in the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); sd_journal_close(journal); return NULL; } r = sd_journal_get_cursor(journal, &cursor); if (r < 0) { - error("Error getting current cursor: %s\n", strerror(-r)); + error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); sd_journal_close(journal); return NULL; } @@ -563,10 +568,11 @@ update_iter(gchar **iter_id, sd_journal *journal) gchar *iter_id_short; char *cursor; int r; + char errbuf[STRERROR_BUF_LEN]; r = sd_journal_get_cursor(journal, &cursor); if (r < 0) { - error("Error getting current cursor: %s\n", strerror(-r)); + error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return false; } @@ -581,6 +587,7 @@ bool journal_iter_seek(gchar **iter_id, sd_journal *journal, gint64 position) { int r; + char errbuf[STRERROR_BUF_LEN]; g_return_val_if_fail(journal != NULL, false); @@ -595,7 +602,7 @@ journal_iter_seek(gchar **iter_id, sd_journal *journal, gint64 position) r = sd_journal_previous_skip(journal, -position); if (r < 0) { - error("Error seeking to the requested position: %s\n", strerror(-r)); + error("Error seeking to the requested position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return false; } @@ -612,20 +619,21 @@ journal_iter_get_data(gchar **iter_id, sd_journal *journal, gboolean step_next) { gchar *d; int r; + char errbuf[STRERROR_BUF_LEN]; g_return_val_if_fail(journal != NULL, false); /* Construct the message */ r = get_record_message(journal, TRUE, &d); if (r < 0) { - error("Error getting record message: %s\n", strerror(-r)); + error("Error getting record message: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); return NULL; } if (step_next) { r = sd_journal_next(journal); if (r < 0) { - error("Error advancing to the next record: %s\n", strerror(-r)); + error("Error advancing to the next record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf))); g_free(d); return NULL; } |