diff --git a/linters/tox.ini b/linters/tox.ini index 4a44e50..5d7ed0f 100644 --- a/linters/tox.ini +++ b/linters/tox.ini @@ -15,8 +15,6 @@ commands = cppcheck \ --quiet \ --check-level=exhaustive \ --enable=warning,portability,performance,style \ - --suppress=assignmentInAssert \ - --suppress=assertWithSideEffect \ --suppress=variableScope \ --inline-suppr \ --library=python \ diff --git a/src/dump/main.c b/src/dump/main.c index 814f2c3..142b00d 100644 --- a/src/dump/main.c +++ b/src/dump/main.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "../libs/const.h" #include "../libs/errors.h" diff --git a/src/libs/array.h b/src/libs/array.h index c7e84db..dc62b81 100644 --- a/src/libs/array.h +++ b/src/libs/array.h @@ -22,14 +22,14 @@ #pragma once -#include +#include "tools.h" #define US_ARRAY_LEN(x_array) (sizeof(x_array) / sizeof((x_array)[0])) #define US_ARRAY_ITERATE(x_array, x_start, x_item_ptr, ...) { \ const int m_len = US_ARRAY_LEN(x_array); \ - assert(x_start <= m_len); \ + US_A(x_start <= m_len); \ for (int m_i = x_start; m_i < m_len; ++m_i) { \ __typeof__((x_array)[0]) *const x_item_ptr = &x_array[m_i]; \ __VA_ARGS__ \ diff --git a/src/libs/capture.c b/src/libs/capture.c index 0aa515b..ee2021e 100644 --- a/src/libs/capture.c +++ b/src/libs/capture.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -471,7 +470,7 @@ int us_capture_hwbuf_grab(us_capture_s *cap, us_capture_hwbuf_s **hw) { } int us_capture_hwbuf_release(const us_capture_s *cap, us_capture_hwbuf_s *hw) { - assert(atomic_load(&hw->refs) == 0); + US_A(atomic_load(&hw->refs) == 0); const uint i = hw->buf.index; _LOG_DEBUG("Releasing HW buffer=%u ...", i); if (us_xioctl(cap->run->fd, VIDIOC_QBUF, &hw->buf) < 0) { @@ -556,7 +555,7 @@ static void _v4l2_buffer_copy(const struct v4l2_buffer *src, struct v4l2_buffer struct v4l2_plane *dest_planes = dest->m.planes; memcpy(dest, src, sizeof(struct v4l2_buffer)); if (src->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { - assert(dest_planes); + US_A(dest_planes); dest->m.planes = dest_planes; memcpy(dest->m.planes, src->m.planes, sizeof(struct v4l2_plane) * VIDEO_MAX_PLANES); } @@ -911,7 +910,7 @@ static int _capture_open_io_method(us_capture_s *cap) { switch (cap->io_method) { case V4L2_MEMORY_MMAP: return _capture_open_io_method_mmap(cap); case V4L2_MEMORY_USERPTR: return _capture_open_io_method_userptr(cap); - default: assert(0 && "Unsupported IO method"); + default: US_RAISE("Unsupported IO method"); } return -1; } @@ -972,7 +971,7 @@ static int _capture_open_io_method_mmap(us_capture_s *cap) { _LOG_PERROR("Can't map device buffer=%u", run->n_bufs); return -1; } - assert(hw->raw.data != NULL); + US_A(hw->raw.data != NULL); hw->raw.allocated = buf_size; if (run->capture_mplane) { @@ -1014,7 +1013,7 @@ static int _capture_open_io_method_userptr(us_capture_s *cap) { for (run->n_bufs = 0; run->n_bufs < req.count; ++run->n_bufs) { us_capture_hwbuf_s *hw = &run->bufs[run->n_bufs]; - assert((hw->raw.data = aligned_alloc(page_size, buf_size)) != NULL); + US_A((hw->raw.data = aligned_alloc(page_size, buf_size)) != NULL); memset(hw->raw.data, 0, buf_size); hw->raw.allocated = buf_size; if (run->capture_mplane) { diff --git a/src/libs/drm/drm.c b/src/libs/drm/drm.c index 6d9aac6..618bdf8 100644 --- a/src/libs/drm/drm.c +++ b/src/libs/drm/drm.c @@ -99,7 +99,7 @@ void us_drm_destroy(us_drm_s *drm) { int us_drm_open(us_drm_s *drm, const us_capture_s *cap) { us_drm_runtime_s *const run = drm->run; - assert(run->fd < 0); + US_A(run->fd < 0); switch (_drm_check_status(drm)) { case 0: break; @@ -200,7 +200,7 @@ void us_drm_close(us_drm_s *drm) { if (run->exposing_dma_fd >= 0) { // Нужно подождать, пока dma_fd не освободится, прежде чем прерывать процесс. // Просто на всякий случай. - assert(run->fd >= 0); + US_A(run->fd >= 0); us_drm_wait_for_vsync(drm); run->exposing_dma_fd = -1; } @@ -258,8 +258,8 @@ void us_drm_close(us_drm_s *drm) { int us_drm_ensure_no_signal(us_drm_s *drm) { us_drm_runtime_s *const run = drm->run; - assert(run->fd >= 0); - assert(run->opened > 0); + US_A(run->fd >= 0); + US_A(run->opened > 0); const ldf now_ts = us_get_now_monotonic(); if (run->blank_at_ts == 0) { @@ -284,7 +284,7 @@ int us_drm_ensure_no_signal(us_drm_s *drm) { } int us_drm_dpms_power_off(us_drm_s *drm) { - assert(drm->run->fd >= 0); + US_A(drm->run->fd >= 0); switch (_drm_check_status(drm)) { case 0: break; case US_ERROR_NO_DEVICE: return 0; // Unplugged, nice @@ -300,7 +300,7 @@ int us_drm_dpms_power_off(us_drm_s *drm) { int us_drm_wait_for_vsync(us_drm_s *drm) { us_drm_runtime_s *const run = drm->run; - assert(run->fd >= 0); + US_A(run->fd >= 0); run->blank_at_ts = 0; switch (_drm_check_status(drm)) { @@ -355,8 +355,8 @@ static void _drm_vsync_callback(int fd, uint n_frame, uint sec, uint usec, void int us_drm_expose_stub(us_drm_s *drm, us_drm_stub_e stub, const us_capture_s *cap) { us_drm_runtime_s *const run = drm->run; - assert(run->fd >= 0); - assert(run->opened > 0); + US_A(run->fd >= 0); + US_A(run->opened > 0); run->blank_at_ts = 0; switch (_drm_check_status(drm)) { @@ -369,7 +369,7 @@ int us_drm_expose_stub(us_drm_s *drm, us_drm_stub_e stub, const us_capture_s *ca # define DRAW_MSG(x_msg) us_frametext_draw(run->ft, (x_msg), run->mode.hdisplay, run->mode.vdisplay) switch (stub) { case US_DRM_STUB_BAD_RESOLUTION: { - assert(cap != NULL); + US_A(cap != NULL); char msg[1024]; US_SNPRINTF(msg, 1023, "=== PiKVM ===" @@ -420,8 +420,8 @@ int us_drm_expose_dma(us_drm_s *drm, const us_capture_hwbuf_s *hw) { us_drm_runtime_s *const run = drm->run; us_drm_buffer_s *const buf = &run->bufs[hw->buf.index]; - assert(run->fd >= 0); - assert(run->opened == 0); + US_A(run->fd >= 0); + US_A(run->opened == 0); run->blank_at_ts = 0; switch (_drm_check_status(drm)) { @@ -706,8 +706,8 @@ static drmModeModeInfo *_find_best_mode(drmModeConnector *conn, uint width, uint if (best == NULL) { best = (conn->count_modes > 0 ? &conn->modes[0] : NULL); } - assert(best == NULL || best->hdisplay > 0); - assert(best == NULL || best->vdisplay > 0); + US_A(best == NULL || best->hdisplay > 0); + US_A(best == NULL || best->vdisplay > 0); return best; } diff --git a/src/libs/fpsi.c b/src/libs/fpsi.c index 01c46f8..1c8ce3d 100644 --- a/src/libs/fpsi.c +++ b/src/libs/fpsi.c @@ -56,9 +56,9 @@ void us_fpsi_frame_to_meta(const us_frame_s *frame, us_fpsi_meta_s *meta) { void us_fpsi_update(us_fpsi_s *fpsi, bool bump, const us_fpsi_meta_s *meta) { if (meta != NULL) { - assert(fpsi->with_meta); + US_A(fpsi->with_meta); } else { - assert(!fpsi->with_meta); + US_A(!fpsi->with_meta); } const sll now_ts = us_floor_ms(us_get_now_monotonic()); @@ -68,7 +68,7 @@ void us_fpsi_update(us_fpsi_s *fpsi, bool bump, const us_fpsi_meta_s *meta) { // Fast mutex-less store method ull state = (ull)fpsi->accum & 0xFFFF; if (fpsi->with_meta) { - assert(meta != NULL); + US_A(meta != NULL); state |= (ull)(meta->width & 0xFFFF) << 16; state |= (ull)(meta->height & 0xFFFF) << 32; state |= (ull)(meta->online ? 1 : 0) << 48; @@ -84,7 +84,7 @@ void us_fpsi_update(us_fpsi_s *fpsi, bool bump, const us_fpsi_meta_s *meta) { uint us_fpsi_get(us_fpsi_s *fpsi, us_fpsi_meta_s *meta) { if (meta != NULL) { - assert(fpsi->with_meta); + US_A(fpsi->with_meta); } // Между чтением инфы и времени может быть гонка, diff --git a/src/libs/frame.c b/src/libs/frame.c index bb41d1c..a770969 100644 --- a/src/libs/frame.c +++ b/src/libs/frame.c @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -107,7 +106,7 @@ uint us_frame_get_padding(const us_frame_s *frame) { break; default: - assert(0 && "Unknown format"); + US_RAISE("Unknown format"); } if (bytes_per_pixel > 0 && frame->stride > frame->width) { return (frame->stride - frame->width * bytes_per_pixel); @@ -120,7 +119,7 @@ bool us_is_jpeg(uint format) { } const char *us_fourcc_to_string(uint format, char *buf, uz size) { - assert(size >= 8); + US_A(size >= 8); buf[0] = format & 0x7F; buf[1] = (format >> 8) & 0x7F; buf[2] = (format >> 16) & 0x7F; diff --git a/src/libs/frame.h b/src/libs/frame.h index d39f0f9..74c4551 100644 --- a/src/libs/frame.h +++ b/src/libs/frame.h @@ -84,7 +84,7 @@ typedef struct { static inline void us_frame_encoding_begin(const us_frame_s *src, us_frame_s *dest, uint format) { - assert(src->used > 0); + US_A(src->used > 0); US_FRAME_COPY_META(src, dest); dest->encode_begin_ts = us_get_now_monotonic(); dest->format = format; @@ -93,7 +93,7 @@ static inline void us_frame_encoding_begin(const us_frame_s *src, us_frame_s *de } static inline void us_frame_encoding_end(us_frame_s *dest) { - assert(dest->used > 0); + US_A(dest->used > 0); dest->encode_end_ts = us_get_now_monotonic(); } diff --git a/src/libs/frametext.c b/src/libs/frametext.c index 7429628..d5adfc7 100644 --- a/src/libs/frametext.c +++ b/src/libs/frametext.c @@ -84,8 +84,8 @@ To access the nth pixel in a row, right-shift by n. */ void us_frametext_draw(us_frametext_s *ft, const char *text, uint width, uint height) { - assert(width > 0); - assert(height > 0); + US_A(width > 0); + US_A(height > 0); us_frame_s *const frame = ft->frame; diff --git a/src/libs/list.h b/src/libs/list.h index 918ffdf..ebae607 100644 --- a/src/libs/list.h +++ b/src/libs/list.h @@ -22,7 +22,7 @@ #pragma once -#include +#include "tools.h" #define US_LIST_DECLARE \ @@ -71,6 +71,6 @@ #define US_LIST_REMOVE_C(x_first, x_item, x_count) { \ US_LIST_REMOVE(x_first, x_item); \ - assert((x_count) >= 1); \ + US_A((x_count) >= 1); \ --(x_count); \ } diff --git a/src/libs/logging.h b/src/libs/logging.h index 5f17c1c..18601b1 100644 --- a/src/libs/logging.h +++ b/src/libs/logging.h @@ -28,7 +28,6 @@ #include #include #include -#include #include diff --git a/src/libs/memsink.c b/src/libs/memsink.c index 7a5e181..71ca94c 100644 --- a/src/libs/memsink.c +++ b/src/libs/memsink.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -110,7 +109,7 @@ bool us_memsink_server_check(us_memsink_s *sink, const us_frame_s *frame) { // Если frame == NULL, то только проверяем наличие клиентов // или необходимость инициализировать память. - assert(sink->server); + US_A(sink->server); if (sink->mem->magic != US_MEMSINK_MAGIC || sink->mem->version != US_MEMSINK_VERSION) { // Если регион памяти не был инициализирован, то нужно что-то туда положить. @@ -162,7 +161,7 @@ bool us_memsink_server_check(us_memsink_s *sink, const us_frame_s *frame) { } int us_memsink_server_put(us_memsink_s *sink, const us_frame_s *frame, bool *key_requested) { - assert(sink->server); + US_A(sink->server); const ldf now = us_get_now_monotonic(); @@ -210,7 +209,7 @@ int us_memsink_server_put(us_memsink_s *sink, const us_frame_s *frame, bool *key } int us_memsink_client_get(us_memsink_s *sink, us_frame_s *frame, bool *key_requested, bool key_required) { - assert(!sink->server); // Client only + US_A(!sink->server); // Client only if (us_flock_timedwait_monotonic(sink->fd, sink->timeout) < 0) { if (errno == EWOULDBLOCK) { diff --git a/src/libs/memsinksh.c b/src/libs/memsinksh.c index 02a2e3f..d93ce7e 100644 --- a/src/libs/memsinksh.c +++ b/src/libs/memsinksh.c @@ -24,11 +24,11 @@ #include #include -#include #include #include "types.h" +#include "tools.h" us_memsink_shared_s *us_memsink_shared_map(int fd, uz data_size) { @@ -40,12 +40,12 @@ us_memsink_shared_s *us_memsink_shared_map(int fd, uz data_size) { if (mem == MAP_FAILED) { return NULL; } - assert(mem != NULL); + US_A(mem != NULL); return mem; } int us_memsink_shared_unmap(us_memsink_shared_s *mem, uz data_size) { - assert(mem != NULL); + US_A(mem != NULL); return munmap(mem, sizeof(us_memsink_shared_s) + data_size); } diff --git a/src/libs/options.c b/src/libs/options.c index 8bc5943..6a0d474 100644 --- a/src/libs/options.c +++ b/src/libs/options.c @@ -25,15 +25,15 @@ #include #include #include -#include #include "types.h" +#include "tools.h" void us_build_short_options(const struct option opts[], char *short_opts, uz size) { memset(short_opts, 0, size); for (uint short_i = 0, opt_i = 0; opts[opt_i].name != NULL; ++opt_i) { - assert(short_i < size - 3); + US_A(short_i < size - 3); if (isalpha(opts[opt_i].val)) { short_opts[short_i] = opts[opt_i].val; ++short_i; diff --git a/src/libs/queue.c b/src/libs/queue.c index c17180c..d72f656 100644 --- a/src/libs/queue.c +++ b/src/libs/queue.c @@ -24,7 +24,6 @@ #include #include -#include #include @@ -41,11 +40,11 @@ us_queue_s *us_queue_init(uint capacity) { US_MUTEX_INIT(q->mutex); pthread_condattr_t attrs; - assert(!pthread_condattr_init(&attrs)); - assert(!pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC)); - assert(!pthread_cond_init(&q->full_cond, &attrs)); - assert(!pthread_cond_init(&q->empty_cond, &attrs)); - assert(!pthread_condattr_destroy(&attrs)); + US_A(!pthread_condattr_init(&attrs)); + US_A(!pthread_condattr_setclock(&attrs, CLOCK_MONOTONIC)); + US_A(!pthread_cond_init(&q->full_cond, &attrs)); + US_A(!pthread_cond_init(&q->empty_cond, &attrs)); + US_A(!pthread_condattr_destroy(&attrs)); return q; } @@ -59,7 +58,7 @@ void us_queue_destroy(us_queue_s *q) { #define _WAIT_OR_UNLOCK(x_var, x_cond) { \ struct timespec m_ts; \ - assert(!clock_gettime(CLOCK_MONOTONIC, &m_ts)); \ + US_A(!clock_gettime(CLOCK_MONOTONIC, &m_ts)); \ us_ld_to_timespec(us_timespec_to_ld(&m_ts) + timeout, &m_ts); \ while (x_var) { \ const int err = pthread_cond_timedwait(&(x_cond), &q->mutex, &m_ts); \ @@ -67,7 +66,7 @@ void us_queue_destroy(us_queue_s *q) { US_MUTEX_UNLOCK(q->mutex); \ return -1; \ } \ - assert(!err); \ + US_A(!err); \ } \ } diff --git a/src/libs/ring.c b/src/libs/ring.c index 3444d5b..3cf6549 100644 --- a/src/libs/ring.c +++ b/src/libs/ring.c @@ -20,8 +20,6 @@ *****************************************************************************/ -#include - #include "ring.h" #include "types.h" @@ -43,7 +41,7 @@ us_ring_s *us_ring_init(uint capacity) { ring->consumer = us_queue_init(capacity); for (uint ri = 0; ri < capacity; ++ri) { ring->places[ri] = ri; // XXX: Just to avoid casting between pointer and uint - assert(!us_queue_put(ring->producer, (void*)(ring->places + ri), 0)); + US_A(!us_queue_put(ring->producer, (void*)(ring->places + ri), 0)); } return ring; } @@ -82,5 +80,5 @@ int _acquire(us_ring_s *ring, us_queue_s *q, ldf timeout) { } void _release(us_ring_s *ring, us_queue_s *q, uint ri) { - assert(!us_queue_put(q, (void*)(ring->places + ri), 0)); + US_A(!us_queue_put(q, (void*)(ring->places + ri), 0)); } diff --git a/src/libs/signal.c b/src/libs/signal.c index e7c461f..aa601ed 100644 --- a/src/libs/signal.c +++ b/src/libs/signal.c @@ -24,7 +24,6 @@ #include #include -#include #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 32 # define HAS_SIGABBREV_NP @@ -58,25 +57,25 @@ char *us_signum_to_string(int signum) { void us_install_signals_handler(us_signal_handler_f handler, bool ignore_sigpipe) { struct sigaction sig_act = {0}; - assert(!sigemptyset(&sig_act.sa_mask)); + US_A(!sigemptyset(&sig_act.sa_mask)); sig_act.sa_handler = handler; - assert(!sigaddset(&sig_act.sa_mask, SIGINT)); - assert(!sigaddset(&sig_act.sa_mask, SIGTERM)); + US_A(!sigaddset(&sig_act.sa_mask, SIGINT)); + US_A(!sigaddset(&sig_act.sa_mask, SIGTERM)); if (!ignore_sigpipe) { - assert(!sigaddset(&sig_act.sa_mask, SIGPIPE)); + US_A(!sigaddset(&sig_act.sa_mask, SIGPIPE)); } US_LOG_DEBUG("Installing SIGINT handler ..."); - assert(!sigaction(SIGINT, &sig_act, NULL)); + US_A(!sigaction(SIGINT, &sig_act, NULL)); US_LOG_DEBUG("Installing SIGTERM handler ..."); - assert(!sigaction(SIGTERM, &sig_act, NULL)); + US_A(!sigaction(SIGTERM, &sig_act, NULL)); if (!ignore_sigpipe) { US_LOG_DEBUG("Installing SIGPIPE handler ..."); - assert(!sigaction(SIGPIPE, &sig_act, NULL)); + US_A(!sigaction(SIGPIPE, &sig_act, NULL)); } else { US_LOG_DEBUG("Ignoring SIGPIPE ..."); - assert(signal(SIGPIPE, SIG_IGN) != SIG_ERR); + US_A(signal(SIGPIPE, SIG_IGN) != SIG_ERR); } } diff --git a/src/libs/threading.h b/src/libs/threading.h index fcd32e9..2f161af 100644 --- a/src/libs/threading.h +++ b/src/libs/threading.h @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -47,8 +46,8 @@ # define US_THREAD_NAME_SIZE ((uz)16) #endif -#define US_THREAD_CREATE(x_tid, x_func, x_arg) assert(!pthread_create(&(x_tid), NULL, (x_func), (x_arg))) -#define US_THREAD_JOIN(x_tid) assert(!pthread_join((x_tid), NULL)) +#define US_THREAD_CREATE(x_tid, x_func, x_arg) US_A(!pthread_create(&(x_tid), NULL, (x_func), (x_arg))) +#define US_THREAD_JOIN(x_tid) US_A(!pthread_join((x_tid), NULL)) #ifdef WITH_PTHREAD_NP # define US_THREAD_RENAME(x_fmt, ...) { \ @@ -65,16 +64,16 @@ us_thread_block_signals(); \ } -#define US_MUTEX_INIT(x_mutex) assert(!pthread_mutex_init(&(x_mutex), NULL)) -#define US_MUTEX_DESTROY(x_mutex) assert(!pthread_mutex_destroy(&(x_mutex))) -#define US_MUTEX_LOCK(x_mutex) assert(!pthread_mutex_lock(&(x_mutex))) -#define US_MUTEX_UNLOCK(x_mutex) assert(!pthread_mutex_unlock(&(x_mutex))) +#define US_MUTEX_INIT(x_mutex) US_A(!pthread_mutex_init(&(x_mutex), NULL)) +#define US_MUTEX_DESTROY(x_mutex) US_A(!pthread_mutex_destroy(&(x_mutex))) +#define US_MUTEX_LOCK(x_mutex) US_A(!pthread_mutex_lock(&(x_mutex))) +#define US_MUTEX_UNLOCK(x_mutex) US_A(!pthread_mutex_unlock(&(x_mutex))) -#define US_COND_INIT(x_cond) assert(!pthread_cond_init(&(x_cond), NULL)) -#define US_COND_DESTROY(x_cond) assert(!pthread_cond_destroy(&(x_cond))) -#define US_COND_SIGNAL(x_cond) assert(!pthread_cond_signal(&(x_cond))) -#define US_COND_BROADCAST(x_cond) assert(!pthread_cond_broadcast(&(x_cond))) -#define US_COND_WAIT_FOR(x_var, x_cond, x_mutex) { while(!(x_var)) assert(!pthread_cond_wait(&(x_cond), &(x_mutex))); } +#define US_COND_INIT(x_cond) US_A(!pthread_cond_init(&(x_cond), NULL)) +#define US_COND_DESTROY(x_cond) US_A(!pthread_cond_destroy(&(x_cond))) +#define US_COND_SIGNAL(x_cond) US_A(!pthread_cond_signal(&(x_cond))) +#define US_COND_BROADCAST(x_cond) US_A(!pthread_cond_broadcast(&(x_cond))) +#define US_COND_WAIT_FOR(x_var, x_cond, x_mutex) { while(!(x_var)) US_A(!pthread_cond_wait(&(x_cond), &(x_mutex))); } #ifdef WITH_PTHREAD_NP @@ -114,7 +113,7 @@ INLINE void us_thread_get_name(char *name) { // Always required for logging const pid_t tid = syscall(SYS_gettid); #elif defined(__FreeBSD__) long id; - assert(!syscall(SYS_thr_self, &id)); + US_A(!syscall(SYS_thr_self, &id)); const pid_t tid = id; #elif defined(__OpenBSD__) const pid_t tid = syscall(SYS_getthrid); @@ -135,8 +134,8 @@ INLINE void us_thread_get_name(char *name) { // Always required for logging INLINE void us_thread_block_signals(void) { sigset_t mask; - assert(!sigemptyset(&mask)); - assert(!sigaddset(&mask, SIGINT)); - assert(!sigaddset(&mask, SIGTERM)); - assert(!pthread_sigmask(SIG_BLOCK, &mask, NULL)); + US_A(!sigemptyset(&mask)); + US_A(!sigaddset(&mask, SIGINT)); + US_A(!sigaddset(&mask, SIGTERM)); + US_A(!pthread_sigmask(SIG_BLOCK, &mask, NULL)); } diff --git a/src/libs/tools.h b/src/libs/tools.h index 8d54dcf..ffad912 100644 --- a/src/libs/tools.h +++ b/src/libs/tools.h @@ -51,14 +51,17 @@ #define INLINE inline __attribute__((always_inline)) -#define US_CALLOC(x_dest, x_nmemb) assert(((x_dest) = calloc((x_nmemb), sizeof(*(x_dest)))) != NULL) -#define US_REALLOC(x_dest, x_nmemb) assert(((x_dest) = realloc((x_dest), (x_nmemb) * sizeof(*(x_dest)))) != NULL) +#define US_A(x_arg) { const bool m_ar = (x_arg); assert(m_ar && #x_arg); } +#define US_RAISE(x_msg) assert(0 && x_msg) + +#define US_CALLOC(x_dest, x_nmemb) US_A(((x_dest) = calloc((x_nmemb), sizeof(*(x_dest)))) != NULL) +#define US_REALLOC(x_dest, x_nmemb) US_A(((x_dest) = realloc((x_dest), (x_nmemb) * sizeof(*(x_dest)))) != NULL) #define US_DELETE(x_dest, x_free) { if (x_dest) { x_free(x_dest); x_dest = NULL; } } #define US_CLOSE_FD(x_dest) { if (x_dest >= 0) { close(x_dest); x_dest = -1; } } #define US_MEMSET_ZERO(x_obj) memset(&(x_obj), 0, sizeof(x_obj)) -#define US_SNPRINTF(x_dest, x_size, x_fmt, ...) assert(snprintf((x_dest), (x_size), (x_fmt), ##__VA_ARGS__) > 0) -#define US_ASPRINTF(x_dest, x_fmt, ...) assert(asprintf(&(x_dest), (x_fmt), ##__VA_ARGS__) > 0) +#define US_SNPRINTF(x_dest, x_size, x_fmt, ...) US_A(snprintf((x_dest), (x_size), (x_fmt), ##__VA_ARGS__) > 0) +#define US_ASPRINTF(x_dest, x_fmt, ...) US_A(asprintf(&(x_dest), (x_fmt), ##__VA_ARGS__) > 0) #define US_MIN(x_a, x_b) ({ \ __typeof__(x_a) m_a = (x_a); \ @@ -85,7 +88,7 @@ INLINE char *us_strdup(const char *str) { char *const new = strdup(str); - assert(new != NULL); + US_A(new != NULL); return new; } @@ -115,7 +118,7 @@ INLINE u32 us_triple_u32(u32 x) { INLINE void us_get_now(clockid_t clk_id, time_t *sec, long *msec) { struct timespec ts; - assert(!clock_gettime(clk_id, &ts)); + US_A(!clock_gettime(clk_id, &ts)); *sec = ts.tv_sec; *msec = round(ts.tv_nsec / 1.0e6); @@ -134,7 +137,7 @@ INLINE ldf us_get_now_monotonic(void) { INLINE u64 us_get_now_monotonic_u64(void) { struct timespec ts; - assert(!clock_gettime(CLOCK_MONOTONIC, &ts)); + US_A(!clock_gettime(CLOCK_MONOTONIC, &ts)); return (u64)(ts.tv_nsec / 1000) + (u64)ts.tv_sec * 1000000; } diff --git a/src/libs/unjpeg.c b/src/libs/unjpeg.c index 0f21b61..3c7f532 100644 --- a/src/libs/unjpeg.c +++ b/src/libs/unjpeg.c @@ -24,12 +24,12 @@ #include #include -#include #include #include #include "types.h" +#include "tools.h" #include "logging.h" #include "frame.h" @@ -45,7 +45,7 @@ static void _jpeg_error_handler(j_common_ptr jpeg); int us_unjpeg(const us_frame_s *src, us_frame_s *dest, bool decode) { - assert(us_is_jpeg(src->format)); + US_A(us_is_jpeg(src->format)); volatile int retval = 0; diff --git a/src/ustreamer/encoder.c b/src/ustreamer/encoder.c index 85826f8..f059466 100644 --- a/src/ustreamer/encoder.c +++ b/src/ustreamer/encoder.c @@ -24,7 +24,6 @@ #include #include -#include #include @@ -113,7 +112,7 @@ void us_encoder_open(us_encoder_s *enc, us_capture_s *cap) { us_encoder_runtime_s *const run = enc->run; us_capture_runtime_s *const cr = cap->run; - assert(run->pool == NULL); + US_A(run->pool == NULL); us_encoder_type_e type = enc->type; uint quality = cap->jpeg_quality; @@ -176,7 +175,7 @@ void us_encoder_open(us_encoder_s *enc, us_capture_s *cap) { } void us_encoder_close(us_encoder_s *enc) { - assert(enc->run->pool != NULL); + US_A(enc->run->pool != NULL); US_DELETE(enc->run->pool, us_workers_pool_destroy); } @@ -226,7 +225,7 @@ static bool _worker_run_job(us_worker_s *wr) { } } else { - assert(0 && "Unknown encoder type"); + US_RAISE("Unknown encoder type"); } US_LOG_VERBOSE("Compressed new JPEG: size=%zu, time=%0.3Lf, worker=%s, buffer=%u", diff --git a/src/ustreamer/encoders/cpu/encoder.c b/src/ustreamer/encoders/cpu/encoder.c index 75366b1..4ae09f8 100644 --- a/src/ustreamer/encoders/cpu/encoder.c +++ b/src/ustreamer/encoders/cpu/encoder.c @@ -30,7 +30,6 @@ #include #include #include -#include #include @@ -140,7 +139,8 @@ void us_cpu_encoder_compress(const us_frame_s *src, us_frame_s *dest, uint quali _jpeg_write_scanlines_bgr24(&jpeg, src); # endif break; - default: assert(0 && "Unsupported input format for CPU encoder"); return; + default: + US_RAISE("Unsupported input format for CPU encoder"); } jpeg_finish_compress(&jpeg); @@ -151,7 +151,7 @@ void us_cpu_encoder_compress(const us_frame_s *src, us_frame_s *dest, uint quali static void _jpeg_set_dest_frame(j_compress_ptr jpeg, us_frame_s *frame) { if (jpeg->dest == NULL) { - assert((jpeg->dest = (struct jpeg_destination_mgr*)(*jpeg->mem->alloc_small)( + US_A((jpeg->dest = (struct jpeg_destination_mgr*)(*jpeg->mem->alloc_small)( (j_common_ptr) jpeg, JPOOL_PERMANENT, sizeof(_jpeg_dest_manager_s) )) != NULL); } @@ -192,8 +192,7 @@ static void _jpeg_write_scanlines_yuv(struct jpeg_compress_struct *jpeg, const u u = data[0]; v = data[2]; } else { - assert(0 && "Unsupported pixel format"); - return; // Makes linter happy + US_RAISE("Unsupported pixel format"); } ptr[0] = y; @@ -247,8 +246,7 @@ static void _jpeg_write_scanlines_yuv_planar(struct jpeg_compress_struct *jpeg, v = chroma1_data[chroma_position]; break; default: - assert(0 && "Unsupported pixel format"); - return; // Makes linter happy + US_RAISE("Unsupported pixel format"); } ptr[0] = y; @@ -371,7 +369,7 @@ static void _jpeg_init_destination(j_compress_ptr jpeg) { _jpeg_dest_manager_s *const dest = (_jpeg_dest_manager_s*)jpeg->dest; // Allocate the output buffer - it will be released when done with image - assert((dest->buf = (JOCTET*)(*jpeg->mem->alloc_small)( + US_A((dest->buf = (JOCTET*)(*jpeg->mem->alloc_small)( (j_common_ptr) jpeg, JPOOL_IMAGE, JPEG_OUTPUT_BUFFER_SIZE * sizeof(JOCTET) )) != NULL); diff --git a/src/ustreamer/encoders/hw/encoder.c b/src/ustreamer/encoders/hw/encoder.c index 326d31e..7e35495 100644 --- a/src/ustreamer/encoders/hw/encoder.c +++ b/src/ustreamer/encoders/hw/encoder.c @@ -28,11 +28,11 @@ #include "encoder.h" #include -#include #include #include "../../../libs/types.h" +#include "../../../libs/tools.h" #include "../../../libs/frame.h" #include "huffman.h" @@ -43,7 +43,7 @@ static bool _is_huffman(const u8 *data); void us_hw_encoder_compress(const us_frame_s *src, us_frame_s *dest) { - assert(us_is_jpeg(src->format)); + US_A(us_is_jpeg(src->format)); _copy_plus_huffman(src, dest); } diff --git a/src/ustreamer/gpio/gpio.c b/src/ustreamer/gpio/gpio.c index 75029da..510c6eb 100644 --- a/src/ustreamer/gpio/gpio.c +++ b/src/ustreamer/gpio/gpio.c @@ -52,7 +52,7 @@ static void _gpio_output_destroy(us_gpio_output_s *out); void us_gpio_init(void) { # ifndef HAVE_GPIOD2 - assert(us_g_gpio.chip == NULL); + US_A(us_g_gpio.chip == NULL); # endif if ( us_g_gpio.prog_running.pin >= 0 @@ -96,10 +96,10 @@ int us_gpio_inner_set(us_gpio_output_s *out, bool on) { int retval = 0; # ifndef HAVE_GPIOD2 - assert(us_g_gpio.chip != NULL); + US_A(us_g_gpio.chip != NULL); # endif - assert(out->line != NULL); - assert(out->on != on); // Must be checked in macro for the performance + US_A(out->line != NULL); + US_A(out->on != on); // Must be checked in macro for the performance US_MUTEX_LOCK(us_g_gpio.mutex); # ifdef HAVE_GPIOD2 @@ -117,24 +117,24 @@ int us_gpio_inner_set(us_gpio_output_s *out, bool on) { } static void _gpio_output_init(us_gpio_output_s *out, struct gpiod_chip *chip) { - assert(out->line == NULL); + US_A(out->line == NULL); US_ASPRINTF(out->consumer, "%s::%s", us_g_gpio.consumer_prefix, out->role); if (out->pin >= 0) { # ifdef HAVE_GPIOD2 struct gpiod_line_settings *line_settings; - assert(line_settings = gpiod_line_settings_new()); - assert(!gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT)); - assert(!gpiod_line_settings_set_output_value(line_settings, false)); + US_A(line_settings = gpiod_line_settings_new()); + US_A(!gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT)); + US_A(!gpiod_line_settings_set_output_value(line_settings, false)); struct gpiod_line_config *line_config; - assert(line_config = gpiod_line_config_new()); + US_A(line_config = gpiod_line_config_new()); const unsigned offset = out->pin; - assert(!gpiod_line_config_add_line_settings(line_config, &offset, 1, line_settings)); + US_A(!gpiod_line_config_add_line_settings(line_config, &offset, 1, line_settings)); struct gpiod_request_config *req_config; - assert(req_config = gpiod_request_config_new()); + US_A(req_config = gpiod_request_config_new()); gpiod_request_config_set_consumer(req_config, out->consumer); if ((out->line = gpiod_chip_request_lines(chip, req_config, line_config)) == NULL) { diff --git a/src/ustreamer/gpio/gpio.h b/src/ustreamer/gpio/gpio.h index cc29b6f..8bf3d5c 100644 --- a/src/ustreamer/gpio/gpio.h +++ b/src/ustreamer/gpio/gpio.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/src/ustreamer/http/server.c b/src/ustreamer/http/server.c index 1a83353..cbd34c6 100644 --- a/src/ustreamer/http/server.c +++ b/src/ustreamer/http/server.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -102,12 +101,12 @@ static bool _expose_frame(us_server_s *server, const us_frame_s *frame); #define _LOG_VERBOSE(x_msg, ...) US_LOG_VERBOSE("HTTP: " x_msg, ##__VA_ARGS__) #define _LOG_DEBUG(x_msg, ...) US_LOG_DEBUG("HTTP: " x_msg, ##__VA_ARGS__) -#define _A_EVBUFFER_NEW(x_buf) assert((x_buf = evbuffer_new()) != NULL) -#define _A_EVBUFFER_ADD(x_buf, x_data, x_size) assert(!evbuffer_add(x_buf, x_data, x_size)) -#define _A_EVBUFFER_ADD_PRINTF(x_buf, x_fmt, ...) assert(evbuffer_add_printf(x_buf, x_fmt, ##__VA_ARGS__) >= 0) +#define _A_EVBUFFER_NEW(x_buf) US_A((x_buf = evbuffer_new()) != NULL) +#define _A_EVBUFFER_ADD(x_buf, x_data, x_size) US_A(!evbuffer_add(x_buf, x_data, x_size)) +#define _A_EVBUFFER_ADD_PRINTF(x_buf, x_fmt, ...) US_A(evbuffer_add_printf(x_buf, x_fmt, ##__VA_ARGS__) >= 0) #define _A_ADD_HEADER(x_req, x_key, x_value) \ - assert(!evhttp_add_header(evhttp_request_get_output_headers(x_req), x_key, x_value)) + US_A(!evhttp_add_header(evhttp_request_get_output_headers(x_req), x_key, x_value)) us_server_s *us_server_init(us_stream_s *stream) { @@ -135,9 +134,9 @@ us_server_s *us_server_init(us_stream_s *stream) { server->stream = stream; server->run = run; - assert(!evthread_use_pthreads()); - assert((run->base = event_base_new()) != NULL); - assert((run->http = evhttp_new(run->base)) != NULL); + US_A(!evthread_use_pthreads()); + US_A((run->base = event_base_new()) != NULL); + US_A((run->http = evhttp_new(run->base)) != NULL); evhttp_set_allowed_methods(run->http, EVHTTP_REQ_GET|EVHTTP_REQ_HEAD|EVHTTP_REQ_OPTIONS); return server; } @@ -188,17 +187,17 @@ int us_server_listen(us_server_s *server) { _LOG_INFO("Enabling the file server: %s", server->static_path); evhttp_set_gencb(run->http, _http_callback_static, (void*)server); } else { - assert(!evhttp_set_cb(run->http, "/", _http_callback_root, (void*)server)); - assert(!evhttp_set_cb(run->http, "/favicon.ico", _http_callback_favicon, (void*)server)); + US_A(!evhttp_set_cb(run->http, "/", _http_callback_root, (void*)server)); + US_A(!evhttp_set_cb(run->http, "/favicon.ico", _http_callback_favicon, (void*)server)); } - assert(!evhttp_set_cb(run->http, "/state", _http_callback_state, (void*)server)); - assert(!evhttp_set_cb(run->http, "/snapshot", _http_callback_snapshot, (void*)server)); - assert(!evhttp_set_cb(run->http, "/stream", _http_callback_stream, (void*)server)); + US_A(!evhttp_set_cb(run->http, "/state", _http_callback_state, (void*)server)); + US_A(!evhttp_set_cb(run->http, "/snapshot", _http_callback_snapshot, (void*)server)); + US_A(!evhttp_set_cb(run->http, "/stream", _http_callback_stream, (void*)server)); } us_frame_copy(stream->run->blank->jpeg, ex->frame); - assert((run->refresher = event_new(run->base, -1, 0, _http_refresher, server)) != NULL); + US_A((run->refresher = event_new(run->base, -1, 0, _http_refresher, server)) != NULL); stream->run->http->jpeg_refresher = run->refresher; evhttp_set_timeout(run->http, server->timeout); @@ -612,7 +611,7 @@ static void _http_callback_stream(struct evhttp_request *req, void *v_server) { if (server->tcp_nodelay && run->ext_fd >= 0) { _LOG_DEBUG("Setting up TCP_NODELAY to the client %s ...", client->hostport); const evutil_socket_t fd = bufferevent_getfd(buf_event); - assert(fd >= 0); + US_A(fd >= 0); int on = 1; if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&on, sizeof(on)) != 0) { _LOG_PERROR("Can't set TCP_NODELAY to the client %s", client->hostport); @@ -703,7 +702,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c ADD_ADVANCE_HEADERS; } - assert(!bufferevent_write_buffer(buf_event, buf)); + US_A(!bufferevent_write_buffer(buf_event, buf)); client->need_initial = false; } @@ -763,7 +762,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c ADD_ADVANCE_HEADERS; } - assert(!bufferevent_write_buffer(buf_event, buf)); + US_A(!bufferevent_write_buffer(buf_event, buf)); evbuffer_free(buf); bufferevent_setcb(buf_event, NULL, NULL, _http_callback_stream_error, (void*)client); diff --git a/src/ustreamer/http/static.c b/src/ustreamer/http/static.c index 699ebde..99dc271 100644 --- a/src/ustreamer/http/static.c +++ b/src/ustreamer/http/static.c @@ -26,7 +26,6 @@ #include #include #include -#include #include @@ -46,7 +45,7 @@ char *us_find_static_file_path(const char *root_path, const char *req_path) { } US_CALLOC(path, strlen(root_path) + strlen(simplified_path) + 16); // + reserved for /index.html - assert(sprintf(path, "%s/%s", root_path, simplified_path) > 0); + US_A(sprintf(path, "%s/%s", root_path, simplified_path) > 0); struct stat st; # define LOAD_STAT { \ diff --git a/src/ustreamer/http/systemd/systemd.c b/src/ustreamer/http/systemd/systemd.c index ae4f421..8c42bbe 100644 --- a/src/ustreamer/http/systemd/systemd.c +++ b/src/ustreamer/http/systemd/systemd.c @@ -23,7 +23,6 @@ #include "systemd.h" #include -#include #include #include @@ -47,7 +46,7 @@ evutil_socket_t us_evhttp_bind_systemd(struct evhttp *http) { } fd = SD_LISTEN_FDS_START; - assert(!evutil_make_socket_nonblocking(fd)); + US_A(!evutil_make_socket_nonblocking(fd)); if (evhttp_accept_socket(http, fd) < 0) { US_LOG_PERROR("HTTP: Can't evhttp_accept_socket() systemd socket"); diff --git a/src/ustreamer/http/tools.c b/src/ustreamer/http/tools.c index e6b2678..97cd7bb 100644 --- a/src/ustreamer/http/tools.c +++ b/src/ustreamer/http/tools.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -54,8 +53,8 @@ evutil_socket_t us_evhttp_bind_unix(struct evhttp *http, const char *path, bool addr.sun_family = AF_UNIX; const evutil_socket_t fd = socket(AF_UNIX, SOCK_STREAM, 0); - assert(fd >= 0); - assert(!evutil_make_socket_nonblocking(fd)); + US_A(fd >= 0); + US_A(!evutil_make_socket_nonblocking(fd)); if (rm && unlink(path) < 0) { if (errno != ENOENT) { @@ -99,7 +98,7 @@ char *us_evhttp_get_hostport(struct evhttp_request *req) { const char *xff = us_evhttp_get_header(req, "X-Forwarded-For"); if (xff != NULL) { US_DELETE(addr, free); - assert((addr = strndup(xff, 1024)) != NULL); + US_A((addr = strndup(xff, 1024)) != NULL); for (uint i = 0; addr[i]; ++i) { if (addr[i] == ',') { addr[i] = '\0'; diff --git a/src/ustreamer/m2m.c b/src/ustreamer/m2m.c index 5eef93e..d0b08ae 100644 --- a/src/ustreamer/m2m.c +++ b/src/ustreamer/m2m.c @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -89,7 +88,7 @@ us_m2m_encoder_s *us_m2m_mjpeg_encoder_init(const char *name, const char *path, double bitrate = log10(quality) * (b_max - b_min) / 2 + b_min; bitrate = step * round(bitrate / step); bitrate *= 1000; // From Kbps - assert(bitrate > 0); + US_A(bitrate > 0); return _m2m_encoder_init(name, path, V4L2_PIX_FMT_MJPEG, bitrate, 0, 0, true, false); } @@ -417,7 +416,7 @@ static int _m2m_encoder_init_buffers( _LOG_PERROR("Can't map %s buffer=%u", name, *n_bufs_ptr); goto error; } - assert((*bufs_ptr)[*n_bufs_ptr].data != NULL); + US_A((*bufs_ptr)[*n_bufs_ptr].data != NULL); (*bufs_ptr)[*n_bufs_ptr].allocated = plane.length; _LOG_DEBUG("Queuing %s buffer=%u ...", name, *n_bufs_ptr); @@ -492,7 +491,7 @@ static int _m2m_encoder_compress_raw( ) { us_m2m_encoder_runtime_s *const run = enc->run; - assert(run->ready); + US_A(run->ready); if (force_key) { struct v4l2_control ctl = {0}; diff --git a/src/ustreamer/main.c b/src/ustreamer/main.c index b828b2c..d758080 100644 --- a/src/ustreamer/main.c +++ b/src/ustreamer/main.c @@ -46,10 +46,10 @@ static us_server_s *_g_server = NULL; static void _block_thread_signals(void) { sigset_t mask; - assert(!sigemptyset(&mask)); - assert(!sigaddset(&mask, SIGINT)); - assert(!sigaddset(&mask, SIGTERM)); - assert(!pthread_sigmask(SIG_BLOCK, &mask, NULL)); + US_A(!sigemptyset(&mask)); + US_A(!sigaddset(&mask, SIGINT)); + US_A(!sigaddset(&mask, SIGTERM)); + US_A(!pthread_sigmask(SIG_BLOCK, &mask, NULL)); } static void *_stream_loop_thread(void *arg) { @@ -77,7 +77,7 @@ static void _signal_handler(int signum) { } int main(int argc, char *argv[]) { - assert(argc >= 0); + US_A(argc >= 0); int exit_code = 0; US_LOGGING_INIT; diff --git a/src/ustreamer/options.c b/src/ustreamer/options.c index f766ed9..e2a777b 100644 --- a/src/ustreamer/options.c +++ b/src/ustreamer/options.c @@ -30,10 +30,10 @@ #include #include #include -#include #include "../libs/types.h" #include "../libs/const.h" +#include "../libs/tools.h" #include "../libs/logging.h" #include "../libs/process.h" #include "../libs/frame.h" @@ -358,7 +358,7 @@ int us_options_parse( printf("Invalid height of '%s=%s': min=%u, max=%u\n", x_name, optarg, US_VIDEO_MIN_HEIGHT, US_VIDEO_MAX_HEIGHT); \ return -1; \ case 0: break; \ - default: assert(0 && "Unknown error"); \ + default: US_RAISE("Unknown error"); \ } \ break; \ } diff --git a/src/ustreamer/stream.c b/src/ustreamer/stream.c index 3201027..2112e63 100644 --- a/src/ustreamer/stream.c +++ b/src/ustreamer/stream.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -199,7 +198,7 @@ void us_stream_loop(us_stream_s *stream) { CREATE_WORKER((stream->raw_sink != NULL), raw_ctx, _raw_thread, 2); CREATE_WORKER((stream->h264_sink != NULL), h264_ctx, _h264_thread, cap->run->n_bufs); # ifdef WITH_V4P - CREATE_WORKER((stream->drm != NULL), drm_ctx, _drm_thread, cap->run->n_bufs); // cppcheck-suppress assertWithSideEffect + CREATE_WORKER((stream->drm != NULL), drm_ctx, _drm_thread, cap->run->n_bufs); # endif # undef CREATE_WORKER @@ -528,7 +527,7 @@ static us_capture_hwbuf_s *_get_latest_hw(us_queue_s *q) { } while (!us_queue_is_empty(q)) { // Берем только самый свежий кадр us_capture_hwbuf_decref(hw); - assert(!us_queue_get(q, (void**)&hw, 0)); + US_A(!us_queue_get(q, (void**)&hw, 0)); } return hw; } diff --git a/src/ustreamer/workers.c b/src/ustreamer/workers.c index 5174a9d..e1810dd 100644 --- a/src/ustreamer/workers.c +++ b/src/ustreamer/workers.c @@ -122,7 +122,7 @@ us_worker_s *us_workers_pool_wait(us_workers_pool_s *pool) { found = wr; } }); - assert(found != NULL); + US_A(found != NULL); US_LIST_REMOVE(pool->workers, found); US_LIST_APPEND(pool->workers, found); // Перемещаем в конец списка diff --git a/src/v4p/main.c b/src/v4p/main.c index 540f4cd..06ab35a 100644 --- a/src/v4p/main.c +++ b/src/v4p/main.c @@ -28,7 +28,6 @@ #include #include #include -#include #include @@ -245,11 +244,11 @@ static void _main_loop(void) { static void *_follower_thread(void *v_unix_follow) { // cppcheck-suppress constParameterCallback US_THREAD_SETTLE("follower"); const char *path = v_unix_follow; - assert(path != NULL); + US_A(path != NULL); while (!atomic_load(&_g_stop)) { int fd = socket(AF_UNIX, SOCK_STREAM, 0); - assert(fd >= 0); + US_A(fd >= 0); struct sockaddr_un addr = {0}; strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);