core: fix checking for busy lines
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 2 Mar 2017 15:59:27 +0000 (16:59 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 2 Mar 2017 15:59:27 +0000 (16:59 +0100)
If we have a bulk object containing only a single line passed to
verify_line_bulk(), we end up not checking if the line was previously
requested.

Fix it by starting the iteration at offset 0 instead of 1 and skipping
the line owner check for i == 0.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
src/lib/core.c

index 4d5be57aa676903589c1a23b97b4ce686520843c..cefa9859c3230c51882b921a5e42ff628faf2342 100644 (file)
@@ -533,10 +533,10 @@ static bool verify_line_bulk(struct gpiod_line_bulk *bulk)
 
        chip = gpiod_line_get_chip(bulk->lines[0]);
 
-       for (i = 1; i < bulk->num_lines; i++) {
+       for (i = 0; i < bulk->num_lines; i++) {
                line = bulk->lines[i];
 
-               if (chip != gpiod_line_get_chip(line)) {
+               if (i > 0 && chip != gpiod_line_get_chip(line)) {
                        set_last_error(GPIOD_EBULKINCOH);
                        return false;
                }