Falk Hueffner <falk@debian.org> writes:
> I can't imagine any sensible code whatsoever that triggers this
> warning but does not have logical errors. Can you show how it is used?
Here are all the source lines from net-snmp 5.2.3-7etch4 that
trigger this warning.
snmplib/data_list.c:108
netsnmp_assert("list key" == "is unique"); /* always fail */
snmplib/data_list.c:117
netsnmp_assert("list key" == "is unique"); /* always fail */
agent/mibgroup/mibII/ip.c:240
netsnmp_assert("cache" == "valid"); /* always false */
agent/mibgroup/mibII/tcp.c:205
netsnmp_assert("cache" == "valid"); /* always false */
agent/mibgroup/mibII/icmp.c:169
netsnmp_assert("cache" == "valid"); /* always false */
agent/mibgroup/mibII/udp.c:192
netsnmp_assert("cache" == "valid"); /* always false */
agent/mibgroup/ip-mib/data_access/ipaddress_common.c:239
netsnmp_assert("ipaddress_entry_set" == "unknown mode");
agent/agent_registry.c:512
netsnmp_assert("registration" != "duplicate");
agent/agent_registry.c:606
netsnmp_assert("register context" == "reginfo->contextName");
include/net-snmp/library/snmp_assert.h #defines netsnmp_assert(x)
either as assert(x) or as something that logs the expression if
the assertion fails. So, I guess the string literals are a way
to include a description of a bug in the log when the bug has
been detected by the surrounding "if" statement, rather than by
the assertion itself.
In net-snmp 5.4.1~dfsg-6, these assertions have apparently been
rewritten as netsnmp_assert(!"cache == valid") and similar.
(There are also netsnmp_assert("bad mode in RO handler") and a
few others without the ! operator.) But anyway, gcc is wrong
to claim the result of the == comparisons is unspecified.
Attachment:
pgpDKwZPp30q0.pgp
Description: PGP signature