On Tue, 21 Jan 2025 18:07:41 +0100 Serhii Iliushyk <sil-...@napatech.com> wrote:
> 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> > --- > 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..40002f3343 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) \ > + return 1; > \ > } while (0) > Complex generic macros like this are brittle. Adding a return in the middle of a loop means it will do unexpected exit of function??