Private
Public Access
2
0

aio: added context validity and replace function checks to aio_close()

Added standard context validity check, another check for a replace function
and corrected a return statement to fit our standard code style.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Alex Tereschenko
2016-07-10 17:36:04 +02:00
committed by Brendan Le Foll
parent e43459d031
commit 917a1bd371
2 changed files with 15 additions and 5 deletions

View File

@@ -225,13 +225,22 @@ mraa_aio_read_float(mraa_aio_context dev)
mraa_result_t
mraa_aio_close(mraa_aio_context dev)
{
if (NULL != dev) {
if (dev->adc_in_fp != -1)
close(dev->adc_in_fp);
free(dev);
if (dev == NULL) {
syslog(LOG_ERR, "aio: close: context is invalid");
return MRAA_ERROR_INVALID_HANDLE;
}
return (MRAA_SUCCESS);
if (IS_FUNC_DEFINED(dev, aio_close_replace)) {
return dev->advance_func->aio_close_replace(dev);
}
if (dev->adc_in_fp != -1) {
close(dev->adc_in_fp);
}
free(dev);
return MRAA_SUCCESS;
}
mraa_result_t