From 3427e7402a6df6c7fe90cfaf70455ac22857cd0c 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..fdf302c72 100644 --- a/compat.c +++ b/compat.c @@ -407,6 +407,14 @@ struct iio_context * iio_context_clone(const struct iio_context *old_ctx) if (!attr) goto err_set_errno; + 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; + } + uri = IIO_CALL(iio_attr_get_static_value)(attr); params = IIO_CALL(iio_context_get_params)(old_ctx);