pwm: fixed wrong line ending being checked by strtol
Move from fopen to POSIX open introduced this bug in strtol Signed-off-by: Maximilian von Tschirschnitz <maximilian.tschirschnitz@intel.com> Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
e5c3e491a8
commit
a202b3fd17
@@ -104,7 +104,7 @@ mraa_pwm_read_period(mraa_pwm_context dev)
|
|||||||
|
|
||||||
char *endptr;
|
char *endptr;
|
||||||
long int ret = strtol(output, &endptr, 10);
|
long int ret = strtol(output, &endptr, 10);
|
||||||
if ('\0' != *endptr) {
|
if ('\0' != *endptr && '\n' != *endptr) {
|
||||||
syslog(LOG_ERR, "pwm: Error in string converstion");
|
syslog(LOG_ERR, "pwm: Error in string converstion");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ mraa_pwm_read_duty(mraa_pwm_context dev)
|
|||||||
|
|
||||||
char *endptr;
|
char *endptr;
|
||||||
long int ret = strtol(output, &endptr, 10);
|
long int ret = strtol(output, &endptr, 10);
|
||||||
if ('\0' != *endptr) {
|
if ('\0' != *endptr && '\n' != *endptr) {
|
||||||
syslog(LOG_ERR, "pwm: Error in string converstion");
|
syslog(LOG_ERR, "pwm: Error in string converstion");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user