projects
/
contrib
/
mraa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fefe0a2
)
gpio.c: fail early in case of error when reading file
author
Brendan Le Foll
<brendan.le.foll@intel.com>
Wed, 26 Nov 2014 13:56:27 +0000
(13:56 +0000)
committer
Brendan Le Foll
<brendan.le.foll@intel.com>
Wed, 26 Nov 2014 13:56:33 +0000
(13:56 +0000)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/gpio/gpio.c
patch
|
blob
|
history
diff --git
a/src/gpio/gpio.c
b/src/gpio/gpio.c
index
47d02c4
..
4f87e4f
100644
(file)
--- a/
src/gpio/gpio.c
+++ b/
src/gpio/gpio.c
@@
-450,7
+450,8
@@
mraa_gpio_read(mraa_gpio_context dev)
if (dev->value_fp == -1) {
if (mraa_gpio_get_valfp(dev) != MRAA_SUCCESS) {
- syslog(LOG_ERR, "gpio: Failed to get value file pointer");
+ syslog(LOG_ERR, "gpio: Failed to get value file pointer");
+ return -1;
}
}
else {
@@
-483,8
+484,11
@@
mraa_gpio_write(mraa_gpio_context dev, int value)
}
if (dev->value_fp == -1) {
- mraa_gpio_get_valfp(dev);
+ if (mraa_gpio_get_valfp(dev) != MRAA_SUCCESS) {
+ return MRAA_ERROR_INVALID_RESOURCE;
+ }
}
+
if (lseek(dev->value_fp, 0, SEEK_SET) == -1) {
return MRAA_ERROR_INVALID_RESOURCE;
}