From: Danylo Vodopianov <dvo-...@napatech.com>

CI found couple coverity problems which were fixed in this commit.

CID: 448984, 448982, 448975, 448969, 448968, 448967
API usage errors  (BAD_COMPARE).

Add memcmp return value checking.

Coverity issue: 448984
Fixes: 6e8b7f11205f ("net/ntnic: add categorizer (CAT) FPGA module")

Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com>
---
v2
* replace return with break for macro DO_COMPARE_INDEXS
---
 drivers/net/ntnic/include/hw_mod_backend.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ntnic/include/hw_mod_backend.h 
b/drivers/net/ntnic/include/hw_mod_backend.h
index f91a3ed058..544962751a 100644
--- a/drivers/net/ntnic/include/hw_mod_backend.h
+++ b/drivers/net/ntnic/include/hw_mod_backend.h
@@ -114,10 +114,10 @@ enum {
                typeof(be_module_reg) *temp_be_module = &(be_module_reg);       
              \
                typeof(idx) tmp_idx = (idx);                                    
              \
                typeof(cmp_idx) tmp_cmp_idx = (cmp_idx);                        
              \
-               if ((unsigned int)(tmp_idx) != (unsigned int)(tmp_cmp_idx)) {   
                  \
-                       (void)memcmp(temp_be_module + tmp_idx, 
&temp_be_module[tmp_cmp_idx],      \
-                                    sizeof(type));                             
                  \
-               }                                                               
                  \
+               if ((unsigned int)(tmp_idx) != (unsigned int)(tmp_cmp_idx))     
                \
+                       if (memcmp(temp_be_module + tmp_idx, 
&temp_be_module[tmp_cmp_idx], \
+                               sizeof(type)) == 0) \
+                               break;                                          
    \
        } while (0)
 
 static inline int is_non_zero(const void *addr, size_t n)
-- 
2.45.0

Reply via email to