additional error checking

This commit is contained in:
Florian Stinglmayr 2025-04-24 13:44:33 +02:00
parent 7fcb2addfe
commit 5ef447c629
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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