Skip to content

Commit af1622d

Browse files
committed
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 <[email protected]>
1 parent a82bf21 commit af1622d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

examples/dummy-iiostream.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
#include <stdint.h>
7878
#include <stdio.h>
7979
#include <string.h>
80-
#include <assert.h>
8180
#include <signal.h>
8281
#include <stdio.h>
8382
#include <errno.h>
@@ -92,6 +91,14 @@
9291

9392
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
9493

94+
#define IIO_ENSURE(expr) { \
95+
if (!(expr)) { \
96+
(void) fprintf(stderr, "assertion failed (%s:%d)\n", __FILE__, __LINE__); \
97+
(void) abort(); \
98+
} \
99+
}
100+
101+
95102
static char *name = "iio_dummy_part_no";
96103
static char *trigger_str = "instance1";
97104
static int buffer_length = 1;
@@ -237,8 +244,8 @@ int main (int argc, char **argv)
237244
has_repeat = ((major * 10000) + minor) >= 8 ? true : false;
238245

239246
printf("* Acquiring IIO context\n");
240-
assert((ctx = iio_create_default_context()) && "No context");
241-
assert(iio_context_get_devices_count(ctx) > 0 && "No devices");
247+
IIO_ENSURE((ctx = iio_create_default_context()) && "No context");
248+
IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices");
242249

243250
printf("* Acquiring device %s\n", name);
244251
dev = iio_context_find_device(ctx, name);

0 commit comments

Comments
 (0)