diff options
author | ngie <ngie@FreeBSD.org> | 2016-05-14 22:04:44 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-05-14 22:04:44 +0000 |
commit | f1c0b0f41c0232912e97c0a1adbfe925b48723ea (patch) | |
tree | 16b28e685fad50be012d1cb97de08e2d434c127d /usr.sbin | |
parent | d20d003d02db33d439cc7ec7d18bd8b473e62e7f (diff) | |
download | FreeBSD-src-f1c0b0f41c0232912e97c0a1adbfe925b48723ea.zip FreeBSD-src-f1c0b0f41c0232912e97c0a1adbfe925b48723ea.tar.gz |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c | 6 |
1 files changed, 3 insertions, 3 deletions
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); } |