Skip to contentSkip to conversation

Fix warning due to format mismatch for field width argument to fprintf()

PATCH New Heiko Thiery 1 participant 1 message May 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Fix warning due to format mismatch for field width argument to fprintf()

bnxt.c:66:54: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘unsigned int’ [-Wformat=]

   66 |   fprintf(stdout, "Length is too short, expected 0x%lx\n",
      |                                                    ~~^
      |                                                      |
      |                                                      long unsigned int
      |                                                    %x

---
v2:
- use '%zx' since the value is converted to size_t (thanks to Ben)

 bnxt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bnxt.c +1 -1
index b46db72..2b0ac76 100644
@@ -63,7 +63,7 @@ int bnxt_dump_regs(struct ethtool_drvinfo *info __maybe_unused, struct ethtool_r
 		return 0;
 
 	if (regs->len < (BNXT_PXP_REG_LEN + BNXT_PCIE_STATS_LEN)) {
-		fprintf(stdout, "Length is too short, expected 0x%lx\n",
+		fprintf(stdout, "Length is too short, expected 0x%zx\n",
 			BNXT_PXP_REG_LEN + BNXT_PCIE_STATS_LEN);
 		return -1;
 	}
Signature · 1 line
2.30.0