diff --git a/examples/ad9361-iiostream.c b/examples/ad9361-iiostream.c index 575d0a1c4..410fce440 100644 --- a/examples/ad9361-iiostream.c +++ b/examples/ad9361-iiostream.c @@ -225,10 +225,14 @@ int main (int argc, char **argv) printf("* Acquiring IIO context\n"); if (argc == 1) { - IIO_ENSURE((ctx = iio_create_context(NULL, NULL)) && "No context"); + ctx = iio_create_context(NULL, NULL); + err = iio_err(ctx); + IIO_ENSURE(!err && "No context"); } else if (argc == 2) { - IIO_ENSURE((ctx = iio_create_context(NULL, argv[1])) && "No context"); + ctx = iio_create_context(NULL, argv[1]); + err = iio_err(ctx); + IIO_ENSURE(!err && "No context"); } IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices"); diff --git a/examples/ad9371-iiostream.c b/examples/ad9371-iiostream.c index 75cfb6b83..105894123 100644 --- a/examples/ad9371-iiostream.c +++ b/examples/ad9371-iiostream.c @@ -225,7 +225,10 @@ int main (__notused int argc, __notused char **argv) txcfg.lo_hz = GHZ(2.5); // 2.5 GHz rf frequency printf("* Acquiring IIO context\n"); - IIO_ENSURE((ctx = iio_create_context(NULL, NULL)) && "No context"); + + ctx = iio_create_context(NULL, NULL); + err = iio_err(ctx); + IIO_ENSURE(!err && "No context"); IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices"); printf("* Acquiring AD9371 streaming devices\n"); diff --git a/examples/adrv9002-iiostream.c b/examples/adrv9002-iiostream.c index 79488998d..95a363475 100644 --- a/examples/adrv9002-iiostream.c +++ b/examples/adrv9002-iiostream.c @@ -226,12 +226,14 @@ int main(void) struct iio_device *rx; size_t tx_sample_sz, rx_sample_sz; int ret = EXIT_FAILURE; + int err; if (register_signals() < 0) return EXIT_FAILURE; ctx = iio_create_context(NULL, NULL); - if (!ctx) { + err = iio_err(ctx); + if (ret) { error("Could not create IIO context\n"); return EXIT_FAILURE; } diff --git a/examples/adrv9009-iiostream.c b/examples/adrv9009-iiostream.c index 59a0b4a27..0fc681b6e 100644 --- a/examples/adrv9009-iiostream.c +++ b/examples/adrv9009-iiostream.c @@ -218,7 +218,9 @@ int main (__notused int argc, __notused char **argv) trxcfg.lo_hz = GHZ(2.5); printf("* Acquiring IIO context\n"); - IIO_ENSURE((ctx = iio_create_context(NULL, NULL)) && "No context"); + ctx = iio_create_context(NULL, NULL); + err = iio_err(ctx); + IIO_ENSURE(!err && "No context"); IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices"); printf("* Acquiring ADRV9009 streaming devices\n"); diff --git a/examples/dummy-iiostream.c b/examples/dummy-iiostream.c index 92f67eb88..2cab2a0c3 100644 --- a/examples/dummy-iiostream.c +++ b/examples/dummy-iiostream.c @@ -239,7 +239,9 @@ int main (int argc, char **argv) has_repeat = ((major * 10000) + minor) >= 8 ? true : false; printf("* Acquiring IIO context\n"); - IIO_ENSURE((ctx = iio_create_context(NULL, NULL)) && "No context"); + ctx = iio_create_context(NULL, NULL); + err = iio_err(ctx); + IIO_ENSURE(!err && "No context"); IIO_ENSURE(iio_context_get_devices_count(ctx) > 0 && "No devices"); printf("* Acquiring device %s\n", name); diff --git a/examples/iio-monitor.c b/examples/iio-monitor.c index 1500c39dc..1d865523d 100644 --- a/examples/iio-monitor.c +++ b/examples/iio-monitor.c @@ -251,7 +251,7 @@ static struct iio_context *show_contexts_screen(void) int i; bool free_uri; char **items; - int ret; + int ret, err; screen = initCDKScreen(win); if (!screen) { @@ -261,7 +261,8 @@ static struct iio_context *show_contexts_screen(void) do { scan_ctx = iio_scan(NULL, NULL); - if (!scan_ctx) + err = iio_err(scan_ctx); + if (err) break; num_contexts = iio_scan_get_results_count(scan_ctx); @@ -311,7 +312,8 @@ static struct iio_context *show_contexts_screen(void) if (uri) { ctx = iio_create_context(NULL, uri); - if (ctx == NULL) { + err = iio_err(ctx); + if (err) { char *msg[] = { "Failed to create IIO context." }; popupLabel(screen, (CDK_CSTRING2)msg, 1); } @@ -326,7 +328,7 @@ static struct iio_context *show_contexts_screen(void) free(items[i]); free(items); - } while (!ctx && ret >= 0); + } while (err && ret >= 0); destroyCDKScreen(screen);