common/sfc_efx/base: fix signed/unsigned mismatch warnings
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 1 Dec 2020 07:24:21 +0000 (10:24 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:04 +0000 (16:03 +0100)
Fix signed/unsigned mismatch issues found by Windows build.

Fixes: 34285fd0891d ("common/sfc_efx/base: add match spec validate API")
Fixes: bb71f7e0a35a ("common/sfc_efx/base: add match specs class comparison API")
Fixes: e9d5c5fb6872 ("common/sfc_efx/base: avoid reading past buffer")
Cc: stable@dpdk.org
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/common/sfc_efx/base/efx_mae.c

index cbc1cb2..2f5b167 100644 (file)
@@ -644,7 +644,7 @@ efx_mae_match_spec_field_set(
                goto fail1;
        }
 
-       if (field_id >= desc_set_nentries) {
+       if ((unsigned int)field_id >= desc_set_nentries) {
                rc = EINVAL;
                goto fail2;
        }
@@ -844,7 +844,8 @@ efx_mae_match_spec_is_valid(
        if (field_caps == NULL)
                return (B_FALSE);
 
-       for (field_id = 0; field_id < desc_set_nentries; ++field_id) {
+       for (field_id = 0; (unsigned int)field_id < desc_set_nentries;
+            ++field_id) {
                const efx_mae_mv_desc_t *descp = &desc_setp[field_id];
                efx_mae_field_cap_id_t field_cap_id = descp->emmd_field_cap_id;
                const uint8_t *m_buf = mvp + descp->emmd_mask_offset;
@@ -853,7 +854,7 @@ efx_mae_match_spec_is_valid(
                if (m_size == 0)
                        continue; /* Skip array gap */
 
-               if (field_cap_id >= field_ncaps)
+               if ((unsigned int)field_cap_id >= field_ncaps)
                        break;
 
                switch (field_caps[field_cap_id].emfc_support) {
@@ -1350,14 +1351,15 @@ efx_mae_match_specs_class_cmp(
                return (0);
        }
 
-       for (field_id = 0; field_id < desc_set_nentries; ++field_id) {
+       for (field_id = 0; (unsigned int)field_id < desc_set_nentries;
+            ++field_id) {
                const efx_mae_mv_desc_t *descp = &desc_setp[field_id];
                efx_mae_field_cap_id_t field_cap_id = descp->emmd_field_cap_id;
 
                if (descp->emmd_mask_size == 0)
                        continue; /* Skip array gap */
 
-               if (field_cap_id >= field_ncaps)
+               if ((unsigned int)field_cap_id >= field_ncaps)
                        break;
 
                if (field_caps[field_cap_id].emfc_mask_affects_class) {