if(fseek(f, 0, SEEK_END) || !(len = ftell(f)) || fseek(f, 0, SEEK_SET)) {
logger(mesh, MESHLINK_ERROR, "Cannot get config file size: %s\n", strerror(errno));
meshlink_errno = MESHLINK_ESTORAGE;
- fclose(f);
return false;
}
if(fread(buf, len, 1, f) != 1) {
logger(mesh, MESHLINK_ERROR, "Cannot read config file: %s\n", strerror(errno));
meshlink_errno = MESHLINK_ESTORAGE;
- fclose(f);
return false;
}
if(rename(tmp_path, path)) {
logger(mesh, MESHLINK_ERROR, "Failed to rename `%s' to `%s': %s", tmp_path, path, strerror(errno));
+ fclose(f);
return false;
}
if(fsync(fileno(f))) {
logger(mesh, MESHLINK_ERROR, "Failed to sync `%s': %s", path, strerror(errno));
+ fclose(f);
return false;
}