Skip to content

Commit

Permalink
compat: Fix behaviour of iio_context_clone()
Browse files Browse the repository at this point in the history
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 <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Dec 1, 2023
1 parent 7e57699 commit 3427e74
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 3427e74

Please sign in to comment.