From af1622dbcfc3091426f5d918f3be31b694877639 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Mon, 27 Apr 2020 09:14:09 -0400 Subject: [PATCH] Coverity: Remove remaining asserts that were not caught dummy-iiostream was still using the standard assert, so remove that and replace it with the default macro that is being used in the other files. Signed-off-by: Robin Getz --- examples/dummy-iiostream.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/examples/dummy-iiostream.c b/examples/dummy-iiostream.c index bb987a0bb..c95b41b93 100644 --- a/examples/dummy-iiostream.c +++ b/examples/dummy-iiostream.c @@ -77,7 +77,6 @@ #include #include #include -#include #include #include #include @@ -92,6 +91,14 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#define IIO_ENSURE(expr) { \ + if (!(expr)) { \ + (void) fprintf(stderr, "assertion failed (%s:%d)\n", __FILE__, __LINE__); \ + (void) abort(); \ + } \ +} + + static char *name = "iio_dummy_part_no"; static char *trigger_str = "instance1"; static int buffer_length = 1; @@ -237,8 +244,8 @@ int main (int argc, char **argv) has_repeat = ((major * 10000) + minor) >= 8 ? true : false; printf("* Acquiring IIO context\n"); - assert((ctx = iio_create_default_context()) && "No context"); - assert(iio_context_get_devices_count(ctx) > 0 && "No devices"); + IIO_ENSURE((ctx = iio_create_default_context()) && "No context"); + IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices"); printf("* Acquiring device %s\n", name); dev = iio_context_find_device(ctx, name);