Private
Public Access
2
0

iioc.: remove call to stat before mkdir as superflous

This is especailly true since we don't care about the outcome, or do we? We
probably should check errno for EEXIST and offer an error if the error is
something else

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll
2015-12-21 15:16:08 +00:00
parent fd531abd3d
commit 725ce5e946

View File

@@ -545,17 +545,14 @@ mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger)
struct stat configfs_status; struct stat configfs_status;
struct stat trigger_status; struct stat trigger_status;
char buf[MAX_SIZE]; char buf[MAX_SIZE];
int ret;
if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) { if (stat(IIO_CONFIGFS_TRIGGER, &configfs_status) == 0) {
memset(buf, 0, MAX_SIZE); memset(buf, 0, MAX_SIZE);
snprintf(buf, MAX_SIZE, IIO_CONFIGFS_TRIGGER "%s", trigger); snprintf(buf, MAX_SIZE, IIO_CONFIGFS_TRIGGER "%s", trigger);
if (stat(buf, &trigger_status) != 0) { // we actually don't care if this doesn't succeed, as it just means
if (mkdir(buf, configfs_status.st_mode) == 0) // it's already been initialised
return MRAA_SUCCESS; mkdir(buf, configfs_status.st_mode);
} else {
// trigger folder already created
return MRAA_SUCCESS;
}
} }
return MRAA_ERROR_UNSPECIFIED; return MRAA_ERROR_UNSPECIFIED;