Skip to contentSkip to conversation

net/ipv6: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.

PATCH In review Jiapeng Zhong 2 participants 2 messages Jan 7, 2021 – Jan 9, 2021

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

PATCH 1/1 net/ipv6: warning: %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.

The print format of this parameter does not match, because it is defined as int type, so modify the matching format of this parameter to %d format.

---
 net/ipv6/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/proc.c +1 -1
index d6306aa..26c702b 100644
@@ -169,7 +169,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib)
 		val = atomic_long_read(smib + i);
 		if (!val)
 			continue;
-		snprintf(name, sizeof(name), "Icmp6%sType%u",
+		snprintf(name, sizeof(name), "Icmp6%sType%d",
 			i & 0x100 ?  "Out" : "In", i & 0xff);
 		seq_printf(seq, "%-32s\t%lu\n", name, val);
 	}
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 14 lines · On Thu, 7 Jan 2021 10:47:34 +0800 Jiapeng Zhong wrote:

The print format of this parameter does not match, because it is defined as int type, so modify the matching format of this parameter to %d format.

---
 net/ipv6/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/proc.c +0 -0
index d6306aa..26c702b 100644

net/ipv6/proc.c static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib) · line 175

Quoted 8 lines
net/ipv6/proc.c +1 -1
@@ -169,7 +169,7 @@ static void snmp6_seq_show_icmpv6msg(struct seq_file *seq, atomic_long_t *smib)
 		val = atomic_long_read(smib + i);
 		if (!val)
 			continue;
-		snprintf(name, sizeof(name), "Icmp6%sType%u",
+		snprintf(name, sizeof(name), "Icmp6%sType%d",
 			i & 0x100 ?  "Out" : "In", i & 0xff);
 		seq_printf(seq, "%-32s\t%lu\n", name, val);
 	}

Type can't be negative, there is no reason for @i to be signed. Changing type of @i sounds like a better idea.