app/testpmd: remove useless pointer checks
PATCH 1/1 app/testpmd: remove useless pointer checks
Parameters to this static helper can't be NULL.
str has already been dereferenced in caller.
dst and size point to variable in stack.
--- app/test-pmd/cmdline_flow.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
app/test-pmd/cmdline_flow.c +1 -5
@@ -9338,11 +9338,7 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size)const uint8_t *head = dst;uint32_t left; -/* Check input parameters */ -if ((src ==NULL ) || - (dst ==NULL ) || - (size ==NULL ) || - (*size ==0 )) +if (*size ==0 )return -1 ; left = *size;
Signature · 1 line
2.23.0
24/03/2022 17:15, David Marchand:
Quoted 3 lines
Parameters to this static helper can't be NULL.
str has already been dereferenced in caller.
dst and size point to variable in stack.
The same function is copy/pasted in several places. Why simplifying only this one? because of its static nature?
Shouldn't we make it a common function as other string helpers?
Quoted 10 lines · Thomas Monjalon
24/03/2022 17:15, David Marchand:
Quoted 3 lines
Parameters to this static helper can't be NULL.
str has already been dereferenced in caller.
dst and size point to variable in stack.The same function is copy/pasted in several places. Why simplifying only this one? because of its static nature?
Shouldn't we make it a common function as other string helpers?
Sorry, this thread fell through the cracks.
The issue was raised by covscan:
Error: REVERSE_INULL (CWE-476):dpdk-21.11/app/test-pmd/cmdline_flow.c:7705: deref_ptr: Directly dereferencing pointer "size". dpdk-21.11/app/test-pmd/cmdline_flow.c:7711: check_after_deref:
Null-checking "size" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
# 7709| if ((src == NULL) || # 7710| (dst == NULL) || # 7711|-> (size == NULL) || # 7712| (*size == 0)) # 7713| return -1;
As for the rest of the code, there might be more cleanups to do, as followups.
Signature · 1 line
David Marchand
Ferruh Yigit
AppliedQuoted 22 lines · David Marchand
Quoted 10 lines · Thomas Monjalon
24/03/2022 17:15, David Marchand:
Quoted 3 lines
Parameters to this static helper can't be NULL.
str has already been dereferenced in caller.
dst and size point to variable in stack.The same function is copy/pasted in several places. Why simplifying only this one? because of its static nature?
Shouldn't we make it a common function as other string helpers?
Sorry, this thread fell through the cracks.
The issue was raised by covscan:
Error:
REVERSE_INULL(CWE-476):dpdk-21.11/app/test-pmd/cmdline_flow.c:7705:deref_ptr: Directly dereferencing pointer "size".dpdk-21.11/app/test-pmd/cmdline_flow.c:7711:check_after_deref:
Null-checking "size" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
Quoted 9 lines
# 7709| if ((src == NULL) || # 7710| (dst == NULL) || # 7711|-> (size == NULL) || # 7712| (*size == 0)) # 7713| return -1;As for the rest of the code, there might be more cleanups to do, as followups.
Proceeding with this one as it solves coverity issue,
Applied to dpdk-next-net/main, thanks.