Skip to content

Commit

Permalink
Merge pull request #464 from analogdevicesinc/rgetz-remove-asserts
Browse files Browse the repository at this point in the history
Coverity: Remove remaining asserts that were not caught
  • Loading branch information
rgetz authored Apr 27, 2020
2 parents a82bf21 + af1622d commit 47a505e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/dummy-iiostream.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 47a505e

Please sign in to comment.