X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fsd-journal.c;h=2bad243ea115dc08919af662f49cc47b45488911;hb=c5a10d9ca017be6133154e09383c84c3d5b85f7c;hp=e021d98155e50cacf41bbc6640072e26c557f93c;hpb=a3e6f050de81a9830e52af09d5d38dad9a356e3b;p=elogind.git diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index e021d9815..2bad243ea 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -197,9 +197,7 @@ static void match_free(Match *m) { } static void match_free_if_empty(Match *m) { - assert(m); - - if (m->matches) + if (!m || m->matches) return; match_free(m); @@ -296,17 +294,10 @@ _public_ int sd_journal_add_match(sd_journal *j, const void *data, size_t size) return 0; fail: - if (add_here) - match_free_if_empty(add_here); - - if (j->level2) - match_free_if_empty(j->level2); - - if (j->level1) - match_free_if_empty(j->level1); - - if (j->level0) - match_free_if_empty(j->level0); + match_free_if_empty(add_here); + match_free_if_empty(j->level2); + match_free_if_empty(j->level1); + match_free_if_empty(j->level0); return -ENOMEM; } @@ -415,7 +406,7 @@ _public_ void sd_journal_flush_matches(sd_journal *j) { } static int compare_entry_order(JournalFile *af, Object *_ao, - JournalFile *bf, uint64_t bp) { + JournalFile *bf, uint64_t bp) { uint64_t a, b; Object *ao, *bo; @@ -498,7 +489,7 @@ static int compare_entry_order(JournalFile *af, Object *_ao, return 0; } -static int compare_with_location(JournalFile *af, Object *ao, Location *l) { +_pure_ static int compare_with_location(JournalFile *af, Object *ao, Location *l) { uint64_t a; assert(af); @@ -1251,11 +1242,11 @@ static void check_network(sd_journal *j, int fd) { return; j->on_network = - sfs.f_type == (__SWORD_TYPE) CIFS_MAGIC_NUMBER || - sfs.f_type == (__SWORD_TYPE) CODA_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) NCP_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) NFS_SUPER_MAGIC || - sfs.f_type == (__SWORD_TYPE) SMB_SUPER_MAGIC; + F_TYPE_CMP(sfs.f_type, CIFS_MAGIC_NUMBER) || + F_TYPE_CMP(sfs.f_type, CODA_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, NCP_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, NFS_SUPER_MAGIC) || + F_TYPE_CMP(sfs.f_type, SMB_SUPER_MAGIC); } static int add_file(sd_journal *j, const char *prefix, const char *filename) { @@ -1302,7 +1293,7 @@ static int add_file(sd_journal *j, const char *prefix, const char *filename) { return r; } - log_debug("File %s got added.", f->path); + log_debug("File %s added.", f->path); check_network(j, f->fd); @@ -1330,7 +1321,7 @@ static int remove_file(sd_journal *j, const char *prefix, const char *filename) hashmap_remove(j->files, f->path); - log_debug("File %s got removed.", f->path); + log_debug("File %s removed.", f->path); if (j->current_file == f) { j->current_file = NULL; @@ -1397,7 +1388,7 @@ static int add_directory(sd_journal *j, const char *prefix, const char *dirname) path = NULL; /* avoid freeing in cleanup */ j->current_invalidate_counter ++; - log_debug("Directory %s got added.", m->path); + log_debug("Directory %s added.", m->path); } else if (m->is_root) return 0; @@ -1476,7 +1467,7 @@ static int add_root_directory(sd_journal *j, const char *p) { j->current_invalidate_counter ++; - log_debug("Root directory %s got added.", m->path); + log_debug("Root directory %s added.", m->path); } else if (!m->is_root) return 0; @@ -1537,9 +1528,9 @@ static int remove_directory(sd_journal *j, Directory *d) { hashmap_remove(j->directories_by_path, d->path); if (d->is_root) - log_debug("Root directory %s got removed.", d->path); + log_debug("Root directory %s removed.", d->path); else - log_debug("Directory %s got removed.", d->path); + log_debug("Directory %s removed.", d->path); free(d->path); free(d); @@ -2217,6 +2208,8 @@ _public_ int sd_journal_get_cutoff_realtime_usec(sd_journal *j, uint64_t *from, return -EINVAL; if (!from && !to) return -EINVAL; + if (from == to) + return -EINVAL; HASHMAP_FOREACH(f, j->files, i) { usec_t fr, t; @@ -2256,6 +2249,8 @@ _public_ int sd_journal_get_cutoff_monotonic_usec(sd_journal *j, sd_id128_t boot return -EINVAL; if (!from && !to) return -EINVAL; + if (from == to) + return -EINVAL; HASHMAP_FOREACH(f, j->files, i) { usec_t fr, t;