Once in the loop, fd_chip can be left unclosed if configuration file
does not match the system and next iteration is required.
This commit makes fd_chip closed just at the end of the current iteration,
before entering another iteration.
Change-Id: I8d7102ba01d0ca30d63e5b634199792368a98297
gpointer base_as_ptr;
bool found = g_hash_table_lookup_extended(chip_to_base, chip_info.label, NULL, &base_as_ptr);
- if (!found)
- continue;
- int base = GPOINTER_TO_INT(base_as_ptr);
-
- if (gpio_pin >= base && gpio_pin < base + chip_info.lines) {
- line = gpio_pin - base;
- break;
- } else {
- cleanup_fd(&fd_chip);
+ if (found) {
+ int base = GPOINTER_TO_INT(base_as_ptr);
+
+ if (gpio_pin >= base && gpio_pin < base + chip_info.lines) {
+ line = gpio_pin - base;
+ break;
+ }
}
+
+ cleanup_fd(&fd_chip);
}
struct gpioline_info line_info;