fsync_dir: remove goto (#2498)

pull/2507/head
Dean Lee 2020-11-09 17:21:48 +08:00 committed by GitHub
parent 519c043a63
commit 1bd1c961ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 18 deletions

View File

@ -49,30 +49,17 @@ void params_sig_handler(int signal) {
}
static int fsync_dir(const char* path){
int result = 0;
int fd = open(path, O_RDONLY, 0755);
if (fd < 0){
result = -1;
goto cleanup;
}
result = fsync(fd);
if (result < 0) {
goto cleanup;
}
cleanup:
int result_close = 0;
if (fd >= 0){
result_close = close(fd);
return -1;
}
int result = fsync(fd);
int result_close = close(fd);
if (result_close < 0) {
return result_close;
} else {
return result;
result = result_close;
}
return result;
}
static int mkdir_p(std::string path) {