From c8a007e08d05b59b238c072865bcaca4106ab67c Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Fri, 1 Dec 2023 14:37:34 +0100 Subject: [PATCH] compat: Fix behaviour of iio_context_clone() The .clone callback was only implemented by the local and network backends in Libiio <= v0.25. Emulate this behaviour by returning -ENOSYS if using a different backend. Signed-off-by: Paul Cercueil --- compat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compat.c b/compat.c index cc1358963..f4897aacb 100644 --- a/compat.c +++ b/compat.c @@ -410,6 +410,14 @@ struct iio_context * iio_context_clone(const struct iio_context *old_ctx) uri = IIO_CALL(iio_attr_get_static_value)(attr); params = IIO_CALL(iio_context_get_params)(old_ctx); + if (strncmp(uri, "local:", sizeof("local:") - 1) + && strncmp(uri, "ip:", sizeof("ip:") - 1)) { + /* The .clone callback was only implemented by the local + * and network backends in Libiio <= v0.25. */ + err = -ENOSYS; + goto err_set_errno; + } + ctx = IIO_CALL(iio_create_context)(params, uri); err = iio_err(ctx); if (err)