From: Youngjae Cho Date: Mon, 3 Feb 2025 04:46:11 +0000 (+0900) Subject: halcc: Add assertion that open_result_file() always returns valid fd on success X-Git-Tag: accepted/tizen/unified/20250205.095531^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_unified_x_asan;p=platform%2Fhal%2Fapi%2Fcommon.git halcc: Add assertion that open_result_file() always returns valid fd on success Logically, the file descriptor received from open_result_file() cannot be invalid(negative) if open_result_file() returned 0. Change-Id: I1b3180fb6c046bf5e4094b010d98970c513d00ae Signed-off-by: Youngjae Cho --- diff --git a/src/hal-api-compatibility-checker.c b/src/hal-api-compatibility-checker.c index 6c56bc7..918715e 100644 --- a/src/hal-api-compatibility-checker.c +++ b/src/hal-api-compatibility-checker.c @@ -278,6 +278,8 @@ static int load_module_compatibility_info(enum hal_module module, if (ret < 0) return ret; + assert(fd > 0); + offset = sizeof(struct compatibility_info) * module; n_read = pread(fd, info, sizeof(*info), offset); if (n_read == -1) { @@ -350,6 +352,8 @@ static int load_module_compatibility_info_fallback(enum hal_module module, return ret; } + assert(fd > 0); + for (enum hal_module index = HAL_MODULE_UNKNOWN + 1; index < HAL_MODULE_END; ++index) { if (!infos[index].initialized) continue;