From f1c0b0f41c0232912e97c0a1adbfe925b48723ea Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 14 May 2016 22:04:44 +0000 Subject: Fix logically dead code pointed out by clang/Coverity parse_context, parse_user_security: test for validity of results from parse_ascii(..) with by casting to int32_t and comparing to -1; comparing unsigned types to negative values will always be false. Reported by: clang, Coverity CID: 1011432, 1011433 MFC after: 3 weeks Sponsored by: EMC / Isilon Storage Division --- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.sbin/bsnmpd') diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c index 2c7b2d2..c2fe4b4 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c @@ -616,8 +616,8 @@ parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) warnx("Suboption 'context-engine' - no argument"); return (-1); } - if ((snmp_client.clen = parse_ascii(val, - snmp_client.cengine, SNMP_ENGINE_ID_SIZ)) < 0) { + if ((int32_t)(snmp_client.clen = parse_ascii(val, + snmp_client.cengine, SNMP_ENGINE_ID_SIZ)) == -1) { warnx("Bad EngineID - %s", val); return (-1); } @@ -655,7 +655,7 @@ parse_user_security(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) } snmp_client.engine.engine_len = parse_ascii(val, snmp_client.engine.engine_id, SNMP_ENGINE_ID_SIZ); - if (snmp_client.engine.engine_len < 0) { + if ((int32_t)snmp_client.engine.engine_len == -1) { warnx("Bad EngineID - %s", val); return (-1); } -- cgit v1.1