Commit b119d3bc authored by Martin Kelly's avatar Martin Kelly Committed by Jonathan Cameron

tools: iio: iio_generic_buffer: make num_loops signed

Currently, num_loops is unsigned, but it's set by strtoll, which returns a
(signed) long long int. This could lead to overflow, and it also makes the
check "num_loops < 0" always be false, since num_loops is unsigned.
Setting num_loops to -1 to loop forever is almost working because num_loops
is getting set to a very high number, but it's technically still incorrect.

Fix this issue by making num_loops signed. This also fixes an error found
by Smatch.
Signed-off-by: default avatarMartin Kelly <mkelly@xevo.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: 55dda0ab ("tools: iio: iio_generic_buffer: allow continuous looping")
Cc: <Stable@vger.kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 9bcf15f7
......@@ -330,7 +330,7 @@ static const struct option longopts[] = {
int main(int argc, char **argv)
{
unsigned long long num_loops = 2;
long long num_loops = 2;
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment