diff options
author | Konrad Kuchciak <k.kuchciak@samsung.com> | 2019-02-11 08:09:35 +0100 |
---|---|---|
committer | Konrad Kuchciak <k.kuchciak@samsung.com> | 2019-02-12 11:59:39 +0100 |
commit | da479b98a011748f82b66bf55b0eb0dd651e1fbf (patch) | |
tree | 4b88bedc42481e16254ee514c9b234cc363f0bf9 | |
parent | 70e51fcc30b715faabb6d2e950f9886b9f2c86d8 (diff) | |
download | peripheral-bus-tizen_5.5_mobile_hotfix.tar.gz peripheral-bus-tizen_5.5_mobile_hotfix.tar.bz2 peripheral-bus-tizen_5.5_mobile_hotfix.zip |
pio: don't close fd if it's value is negativetizen_5.5.m2_releasesubmit/tizen_5.5_wearable_hotfix/20201026.184304submit/tizen_5.5_mobile_hotfix/20201026.185104submit/tizen_5.5/20191031.000004submit/tizen/20190213.063316accepted/tizen/unified/20190214.154131accepted/tizen/5.5/unified/wearable/hotfix/20201027.112349accepted/tizen/5.5/unified/mobile/hotfix/20201027.085723accepted/tizen/5.5/unified/20191031.021436tizen_5.5_wearable_hotfixtizen_5.5_tvtizen_5.5_mobile_hotfixaccepted/tizen_5.5_unified_wearable_hotfixaccepted/tizen_5.5_unified_mobile_hotfix
Additionaly return if fd open failed.
Change-Id: Ica183a00a265a499eb2e09a864062877ef8847fa
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
-rw-r--r-- | src/interface/peripheral_interface_adc.c | 4 | ||||
-rw-r--r-- | src/interface/peripheral_interface_i2c.c | 4 | ||||
-rw-r--r-- | src/interface/peripheral_interface_spi.c | 4 | ||||
-rw-r--r-- | src/interface/peripheral_interface_uart.c | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/src/interface/peripheral_interface_adc.c b/src/interface/peripheral_interface_adc.c index a65a982..623ed74 100644 --- a/src/interface/peripheral_interface_adc.c +++ b/src/interface/peripheral_interface_adc.c @@ -51,6 +51,7 @@ int peripheral_interface_adc_fd_list_create(int device, int channel, GUnixFDList 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(); @@ -66,7 +67,8 @@ int peripheral_interface_adc_fd_list_create(int device, int channel, GUnixFDList *list_out = list; out: - close(fd); + if (fd >= 0) + close(fd); return ret; } diff --git a/src/interface/peripheral_interface_i2c.c b/src/interface/peripheral_interface_i2c.c index 4a06dbc..efcb32b 100644 --- a/src/interface/peripheral_interface_i2c.c +++ b/src/interface/peripheral_interface_i2c.c @@ -57,6 +57,7 @@ int peripheral_interface_i2c_fd_list_create(int bus, int address, GUnixFDList ** 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(); @@ -72,7 +73,8 @@ int peripheral_interface_i2c_fd_list_create(int bus, int address, GUnixFDList ** *list_out = list; out: - close(fd); + if (fd >= 0) + close(fd); return ret; } diff --git a/src/interface/peripheral_interface_spi.c b/src/interface/peripheral_interface_spi.c index 16fea9b..c24d04b 100644 --- a/src/interface/peripheral_interface_spi.c +++ b/src/interface/peripheral_interface_spi.c @@ -50,6 +50,7 @@ int peripheral_interface_spi_fd_list_create(int bus, int cs, GUnixFDList **list_ 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(); @@ -65,7 +66,8 @@ int peripheral_interface_spi_fd_list_create(int bus, int cs, GUnixFDList **list_ *list_out = list; out: - close(fd); + if (fd >= 0) + close(fd); return ret; } diff --git a/src/interface/peripheral_interface_uart.c b/src/interface/peripheral_interface_uart.c index cdfe167..f650b42 100644 --- a/src/interface/peripheral_interface_uart.c +++ b/src/interface/peripheral_interface_uart.c @@ -65,6 +65,7 @@ int peripheral_interface_uart_fd_list_create(int port, GUnixFDList **list_out) 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(); @@ -80,7 +81,8 @@ int peripheral_interface_uart_fd_list_create(int port, GUnixFDList **list_out) *list_out = list; out: - close(fd); + if (fd >= 0) + close(fd); return ret; } |