Skip to content

Commit 169f224

Browse files
OmriRitblatroot
authored andcommitted
issue: 4583806 Coverity var_deref_op fixes
Fix Coverity-reported var_deref_op warnings by adding macro-safe Coverity _Pragma() suppressions inside the SYSCALL wrapper to document intentional pointer dereferencing and eliminate false positives. Updated file: - src/core/sock/sock-redirect.h Signed-off-by: Omri Ritblat <[email protected]>
1 parent 3de7ce3 commit 169f224

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/core/sock/sock-redirect.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,32 @@
6464
#include <set>
6565

6666
#ifdef XLIO_STATIC_BUILD
67+
6768
#define XLIO_SYMBOL(_func) xlio_##_func
6869
#define SYSCALL(_func, ...) ::_func(__VA_ARGS__)
6970
#define XLIO_CALL(_func, ...) xlio_##_func(__VA_ARGS__)
7071
#define SYSCALL_ERRNO_UNSUPPORTED(_func, ...) SYSCALL(_func, __VA_ARGS__)
7172
#define VALID_SYSCALL(_func) (true)
7273
#else
7374
#define XLIO_SYMBOL(_func) _func
75+
#ifdef __COVERITY__
76+
#define COVERITY_VAR_DEREF_OP \
77+
_Pragma("coverity compliance deviate \"var_deref_op\" \
78+
\"Intentional dereference; pointer validated elsewhere\"")
79+
#else
80+
#define COVERITY_VAR_DEREF_OP
81+
#endif
82+
7483
#define VALID_SYSCALL(_func) ((orig_os_api._func) != nullptr)
84+
7585
#define SYSCALL(_func, ...) \
76-
((VALID_SYSCALL(_func) ? (void)0 : get_orig_funcs()), \
77-
/* coverity[var_deref_op] */ \
78-
orig_os_api._func(__VA_ARGS__))
86+
__extension__({ \
87+
if (!VALID_SYSCALL(_func)) { \
88+
get_orig_funcs(); \
89+
} \
90+
COVERITY_VAR_DEREF_OP \
91+
orig_os_api._func(__VA_ARGS__); \
92+
})
7993
#define SYSCALL_ERRNO_UNSUPPORTED(_func, ...) \
8094
(VALID_SYSCALL(_func) ? orig_os_api._func(__VA_ARGS__) : ((errno = EOPNOTSUPP), -1))
8195
#define XLIO_CALL(_func, ...) _func(__VA_ARGS__)

src/stats/stats_reader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ void stats_reader_handler(sh_mem_t *p_sh_mem, int pid)
16261626
}
16271627
switch (user_params.print_details_mode) {
16281628
case e_totals:
1629+
/* coverity[forward_null] */
16291630
num_act_inst =
16301631
show_socket_stats(p_sh_mem->skt_inst_arr, NULL, p_sh_mem->max_skt_inst_num,
16311632
&printed_line_num, &p_sh_mem->mc_info, pid);

0 commit comments

Comments
 (0)