Additionaly return if fd open failed.
Change-Id: Ica183a00a265a499eb2e09a864062877ef8847fa
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
ret = __peripheral_interface_adc_fd_open(device, channel, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open adc fd");
+ goto out;
}
list = g_unix_fd_list_new();
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
ret = __peripheral_interface_i2c_fd_open(bus, address, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open i2c fd");
+ goto out;
}
list = g_unix_fd_list_new();
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
ret = __peripheral_interface_spi_fd_open(bus, cs, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open spi fd");
+ goto out;
}
list = g_unix_fd_list_new();
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}
ret = __peripheral_interface_uart_fd_open(port, &fd);
if (ret != PERIPHERAL_ERROR_NONE) {
_E("Failed to open uart fd");
+ goto out;
}
list = g_unix_fd_list_new();
*list_out = list;
out:
- close(fd);
+ if (fd >= 0)
+ close(fd);
return ret;
}