From 6f500ee98a828e3e6d343cb7f46b0bfbb0342d04 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Mon, 9 Nov 2020 17:21:48 +0800 Subject: [PATCH] fsync_dir: remove goto (#2498) old-commit-hash: 1bd1c961efccfa99936dd7e096356af3fa5243ed --- selfdrive/common/params.cc | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 5be7210578..da799d71d7 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -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) {