From ee4add3dd5bdeec7c798d5e3b4a8cc72d28b01fe Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Fri, 4 Jun 2021 16:06:33 +0100 Subject: [PATCH] local: Make local_buffer_enabled_set() return 0 on success Previously, local_buffer_enabled_set() would return a negative value on error, and a positive value on success. The positive value was never needed anywhere, and caused some callers to misinterpret these as errors (by checking "ret != 0" instead of "ret < 0" for the error case). Signed-off-by: Paul Cercueil --- local.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/local.c b/local.c index 8a072537e..2ee73f1b4 100644 --- a/local.c +++ b/local.c @@ -403,10 +403,16 @@ static ssize_t local_write(const struct iio_device *dev, return ret; } -static ssize_t local_buffer_enabled_set(const struct iio_device *dev, bool en) +static int local_buffer_enabled_set(const struct iio_device *dev, bool en) { - return local_write_dev_attr(dev, "buffer/enable", en ? "1" : "0", - 2, false); + int ret; + + ret = (int) local_write_dev_attr(dev, "buffer/enable", en ? "1" : "0", + 2, false); + if (ret < 0) + return ret; + + return 0; } static int local_set_kernel_buffers_count(const struct iio_device *dev,