From bdc716036ad2ff3f9d45ee8f118745dd5bd799b6 Mon Sep 17 00:00:00 2001 From: Chrissie Caulfield Date: Thu, 28 May 2020 07:30:26 +0100 Subject: [PATCH] Some bugs spotted by coverity (#399) --- include/tlist.h | 2 +- lib/ringbuffer.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/tlist.h b/include/tlist.h index bcae55dfe..723d3ecce 100644 --- a/include/tlist.h +++ b/include/tlist.h @@ -191,7 +191,7 @@ static inline void timerlist_expire(struct timerlist *timerlist) uint64_t current_time; current_monotonic_time = qb_util_nano_current_get(); - current_time_from_epoch = current_time = qb_util_nano_from_epoch_get(); + current_time_from_epoch = qb_util_nano_from_epoch_get(); qb_list_for_each_safe(pos, next, &timerlist->timer_head) { diff --git a/lib/ringbuffer.c b/lib/ringbuffer.c index 3a0fb7e12..b0fc79826 100644 --- a/lib/ringbuffer.c +++ b/lib/ringbuffer.c @@ -266,13 +266,13 @@ qb_rb_open_2(const char *name, size_t size, uint32_t flags, if (fd_hdr >= 0) { close(fd_hdr); } - if (rb && (flags & QB_RB_FLAG_CREATE)) { + if (rb && (rb->shared_hdr != MAP_FAILED) && (flags & QB_RB_FLAG_CREATE)) { unlink(rb->shared_hdr->hdr_path); if (rb->notifier.destroy_fn) { (void)rb->notifier.destroy_fn(rb->notifier.instance); } } - if (rb && (rb->shared_hdr != MAP_FAILED && rb->shared_hdr != NULL)) { + if (rb && (rb->shared_hdr != MAP_FAILED)) { munmap(rb->shared_hdr, sizeof(struct qb_ringbuffer_shared_s)); } free(rb);