From 76e3b27b6943142ff726ae3e520530b7ec117d3f Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Mon, 21 Oct 2024 12:04:04 +0200 Subject: [PATCH] Fix false positive in coverity Coverity assumes that casting a void pointer to anything else is tainted, which gives warning when casting the `rd_amcache` field to anything else. Since this is what the field is used for, we mark the cast from `void*` to `HypercoreInfo*` as a false positive. --- tsl/src/hypercore/hypercore_handler.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tsl/src/hypercore/hypercore_handler.c b/tsl/src/hypercore/hypercore_handler.c index 14a29432c..4bfc50495 100644 --- a/tsl/src/hypercore/hypercore_handler.c +++ b/tsl/src/hypercore/hypercore_handler.c @@ -279,14 +279,15 @@ lazy_build_hypercore_info_cache(Relation rel, bool create_chunk_constraints, HypercoreInfo * RelationGetHypercoreInfo(Relation rel) { - if (NULL == rel->rd_amcache) - rel->rd_amcache = lazy_build_hypercore_info_cache(rel, - true /* create constraints */, - NULL /* compressed rel created */); + /*coverity[tainted_data_downcast : FALSE]*/ + HypercoreInfo *info = rel->rd_amcache; - Assert(rel->rd_amcache && OidIsValid(((HypercoreInfo *) rel->rd_amcache)->compressed_relid)); + if (NULL == info) + info = rel->rd_amcache = lazy_build_hypercore_info_cache(rel, true, NULL); - return rel->rd_amcache; + Assert(info && OidIsValid(info->compressed_relid)); + + return info; } static void