From: Youngjae Cho Date: Tue, 25 Jun 2024 01:38:37 +0000 (+0900) Subject: halcc: Fix errno not to be overwritten before returning X-Git-Tag: accepted/tizen/unified/20240625.163203~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F313375%2F1;p=platform%2Fhal%2Fapi%2Fcommon.git halcc: Fix errno not to be overwritten before returning Change-Id: Iddc5f3e1abd43c6a9881fdde55ae354c47850b6a Signed-off-by: Youngjae Cho --- diff --git a/src/hal-api-compatibility-checker.c b/src/hal-api-compatibility-checker.c index a4d29d4..fef9463 100644 --- a/src/hal-api-compatibility-checker.c +++ b/src/hal-api-compatibility-checker.c @@ -350,16 +350,19 @@ static int open_result_file(const char *path, int *fd_out, bool reset) return 0; } + ret = -errno; _E("Failed to create %s, %m", path); - return -errno; + + return ret; } /* set a new file size */ ret = ftruncate(fd, sizeof(struct compatibility_info) * HAL_MODULE_END); if (ret < 0) { + ret = -errno; _E("Failed to ftruncate %s, %m", path); close(fd); - return -errno; + return ret; } /* system_fw:system_fw */ @@ -393,9 +396,10 @@ static int write_module_comaptibility_info(enum hal_module module, offset = sizeof(struct compatibility_info) * module; n_write = pwrite(fd, info, sizeof(*info), offset); if (n_write == -1) { + ret = -errno; _E("Failed to write info, %m"); close(fd); - return -errno; + return ret; } close(fd); @@ -409,6 +413,7 @@ static int load_module_compatibility_info(enum hal_module module, int fd = -1; size_t n_read = -1; off_t offset; + int ret; if (module < HAL_MODULE_UNKNOWN || module >= HAL_MODULE_END) return -EINVAL; @@ -423,8 +428,9 @@ static int load_module_compatibility_info(enum hal_module module, offset = sizeof(struct compatibility_info) * module; n_read = pread(fd, info, sizeof(*info), offset); if (n_read == -1) { + ret = -errno; close(fd); - return -errno; + return ret; } close(fd);