Skip to content

Commit

Permalink
local: Make local_buffer_enabled_set() return 0 on success
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pcercuei committed Jun 10, 2021
1 parent 4b32de5 commit ee4add3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ee4add3

Please sign in to comment.