From: Manish Kurup <manish.kurup@broadcom.com>
To: dev@dpdk.org
Cc: kishore.padmanabha@broadcom.com,
Dakota Sicher <dakota.sicher@broadcom.com>
Subject: [PATCH] net/bnxt: fix compiler warnings
Date: Mon, 5 Oct 2026 15:25:30 -0500 [thread overview]
Message-ID: <20261005202530.18031-1-manish.kurup@broadcom.com> (raw)
From: Dakota Sicher <dakota.sicher@broadcom.com>
Fix a compiler warning in bnxt_tf_pmd_shim for comparison of
differently signed values. Fix compiler warnings for array
out-of-bounds in ulp_bs_pull_lsb and ulp_bs_pull_msb.
Fixes: 1993b267dbcb ("net/bnxt: cleanup ULP parser and mapper")
Signed-off-by: Dakota Sicher <dakota.sicher@broadcom.com>
Signed-off-by: Manish Kurup <manish.kurup@broadcom.com>
---
drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c | 14 +++++++++++---
drivers/net/bnxt/tf_ulp/ulp_utils.h | 14 +++++++-------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
index bfd5f4b230..9a7b9bfe34 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_tf_pmd_shim.c
@@ -140,10 +140,14 @@ static int32_t ulp_pmd_get_mac_by_pci(const char *pci_name, uint8_t *mac)
glob_t gres;
FILE *fp;
int32_t rc = -EINVAL;
+ int32_t pr;
memset(path, 0, sizeof(path));
- sprintf(path, PARENT_PHY_INTF_PATH, pci_name);
-
+ pr = snprintf(path, sizeof(path), PARENT_PHY_INTF_PATH, pci_name);
+ if (unlikely((size_t)pr >= sizeof(path) || pr < 0)) {
+ BNXT_DRV_DBG(ERR, "Error writing path: %s", path);
+ return rc;
+ }
/* There can be only one, no more, no less */
if (glob(path, 0, glob_error_fn, &gres) == 0) {
if (gres.gl_pathc != 1)
@@ -151,7 +155,11 @@ static int32_t ulp_pmd_get_mac_by_pci(const char *pci_name, uint8_t *mac)
/* Replace the PCI address with interface name and get index */
intf_name = basename(gres.gl_pathv[0]);
- sprintf(path, ULP_PRT_MAC_PATH, pci_name, intf_name);
+ pr = snprintf(path, sizeof(path), ULP_PRT_MAC_PATH, pci_name, intf_name);
+ if (unlikely((size_t)pr >= sizeof(path) || pr < 0)) {
+ BNXT_DRV_DBG(ERR, "Error writing path: %s", path);
+ return rc;
+ }
fp = fopen(path, "r");
if (!fp) {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_utils.h b/drivers/net/bnxt/tf_ulp/ulp_utils.h
index ce20f1916f..354217abc6 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_utils.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_utils.h
@@ -699,18 +699,18 @@ ulp_bs_pull_lsb(uint8_t *src, uint8_t *dst, uint32_t size,
{
uint32_t idx;
uint32_t cnt = ULP_BITS_2_BYTE_NR(len);
+ uint32_t rem = len % ULP_BLOB_BYTE;
/* iterate bytewise to get data */
- for (idx = 0; idx < cnt; idx++) {
+ for (idx = 0; idx < cnt && idx < size; idx++) {
ulp_bs_get_lsb(src, offset, ULP_BLOB_BYTE,
&dst[size - 1 - idx]);
offset += ULP_BLOB_BYTE;
- len -= ULP_BLOB_BYTE;
}
/* Extract the last reminder data that is not 8 byte boundary */
- if (len)
- ulp_bs_get_lsb(src, offset, len, &dst[size - 1 - idx]);
+ if (rem && idx < size)
+ ulp_bs_get_lsb(src, offset, rem, &dst[size - 1 - idx]);
}
/*
@@ -764,17 +764,17 @@ ulp_bs_pull_msb(uint8_t *src, uint8_t *dst,
{
uint32_t idx;
uint32_t cnt = ULP_BITS_2_BYTE_NR(len);
+ uint32_t rem = len % ULP_BLOB_BYTE;
/* iterate bytewise to get data */
for (idx = 0; idx < cnt; idx++) {
ulp_bs_get_msb(src, offset, ULP_BLOB_BYTE, &dst[idx]);
offset += ULP_BLOB_BYTE;
- len -= ULP_BLOB_BYTE;
}
/* Extract the last reminder data that is not 8 byte boundary */
- if (len)
- ulp_bs_get_msb(src, offset, len, &dst[idx]);
+ if (rem)
+ ulp_bs_get_msb(src, offset, rem, &dst[idx]);
}
/*
--
2.31.1
reply other threads:[~2026-10-05 20:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261005202530.18031-1-manish.kurup@broadcom.com \
--to=manish.kurup@broadcom.com \
--cc=dakota.sicher@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox