halcc: Add assertion that open_result_file() always returns valid fd on success 84/319084/2 accepted/tizen/9.0/unified/20250206.165033
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 3 Feb 2025 04:46:11 +0000 (13:46 +0900)
committeryoungjae cho <y0.cho@samsung.com>
Tue, 4 Feb 2025 06:13:37 +0000 (06:13 +0000)
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 <y0.cho@samsung.com>
(cherry picked from commit 0d633de92b30f7cf8f7bb88c13da133388295470)

src/hal-api-compatibility-checker.c

index 6c56bc7549e2d57528266d4a8595c85bac30af10..918715ef3e61ed21197d5c55ac6e26c04d330112 100644 (file)
@@ -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;