diff --git a/lib/include/edapi/error.h b/lib/include/edapi/error.h index b235020..afb7514 100644 --- a/lib/include/edapi/error.h +++ b/lib/include/edapi/error.h @@ -22,4 +22,9 @@ typedef enum { */ #define goto_if_error(r, l) do { if (ED_ERROR(r)) goto l; } while(0) +/** + * Return `r` if `b` is true. + */ +#define return_if_true(b, r) do { if (b) return r; } while(0) + #endif diff --git a/lib/src/journal/file.c b/lib/src/journal/file.c index 9438de9..ff8e1f2 100644 --- a/lib/src/journal/file.c +++ b/lib/src/journal/file.c @@ -63,6 +63,9 @@ EDErrorCode ed_journal_file_parse(EDJournalFile *file, char const *filename) gchar *timestamp = NULL; gchar *index = NULL; + return_if_true(file == NULL, ed_error_args); + return_if_true(S_EMPTY(filename), ed_error_args); + new_style = g_regex_new( "Journal\\.([\\dT\\-]+)\\.(\\d+)\\.log", 0, 0, NULL