From 4215a8ab7cc004c617b91a1628dbad3f19fbbe30 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 13 Aug 2020 17:26:00 +0200 Subject: Shrink some code --- zix/ring.c | 4 ++-- zix/thread.h | 14 +++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'zix') diff --git a/zix/ring.c b/zix/ring.c index a62d833..cdbcea8 100644 --- a/zix/ring.c +++ b/zix/ring.c @@ -173,9 +173,9 @@ zix_ring_read(ZixRing* ring, void* dst, uint32_t size) ZIX_READ_BARRIER(); ring->read_head = (r + size) & ring->size_mask; return size; - } else { - return 0; } + + return 0; } uint32_t diff --git a/zix/thread.h b/zix/thread.h index 2af0c5e..e2b59c4 100644 --- a/zix/thread.h +++ b/zix/thread.h @@ -101,17 +101,13 @@ zix_thread_create(ZixThread* thread, const int ret = pthread_create(thread, NULL, function, arg); pthread_attr_destroy(&attr); - if (ret == EAGAIN) { - return ZIX_STATUS_NO_MEM; - } else if (ret == EINVAL) { - return ZIX_STATUS_BAD_ARG; - } else if (ret == EPERM) { - return ZIX_STATUS_BAD_PERMS; - } else if (ret) { - return ZIX_STATUS_ERROR; + switch (ret) { + case EAGAIN: return ZIX_STATUS_NO_MEM; + case EINVAL: return ZIX_STATUS_BAD_ARG; + case EPERM: return ZIX_STATUS_BAD_PERMS; } - return ZIX_STATUS_SUCCESS; + return ret ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; } static inline ZixStatus -- cgit v1.2.1