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/9.0/unified/20250206.165033^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdf02ee60d7a3c79a1e83b85fb2cde811b5bb38a;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 (cherry picked from commit 0d633de92b30f7cf8f7bb88c13da133388295470) --- 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;