From owner-svn-src-all@freebsd.org Mon May 23 05:41:54 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 898B9B465B1; Mon, 23 May 2016 05:41:54 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 655711A9A; Mon, 23 May 2016 05:41:54 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4N5frgU094636; Mon, 23 May 2016 05:41:53 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4N5friJ094634; Mon, 23 May 2016 05:41:53 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201605230541.u4N5friJ094634@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Mon, 23 May 2016 05:41:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r300471 - stable/10/usr.sbin/bsnmpd/tools/libbsnmptools X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2016 05:41:54 -0000 Author: ngie Date: Mon May 23 05:41:53 2016 New Revision: 300471 URL: https://svnweb.freebsd.org/changeset/base/300471 Log: MFC r299712,r299759,r299760,r299761,r299762: r299712: Fix some trivial clang/gcc warnings in bsnmptc.c - By definition, `enum snmp_tc` can't be false (the implied starting sequence index for the enum is 0). Don't test for it being < 0. - Staticize `struct snmp_text_conv` to mute a -Wmissing-variable-declarations warning from clang. - Remove set but unused variable, ptr, in parse_bridge_id(..) and parse_bport_id(..) to mute warning from gcc 4.9+. - Mark value and string unused in snmp_inetaddr2oct(..) and parse_inetaddr(..) as they're just stub functions. r299759: Use calloc instead of memset(.., 0, ..) + malloc r299760: Sort variables in parse_ascii(..) per style(9) r299761: parse_ascii: make count size_t to mute a -Wsign-compare issue count is always unsigned. r299762: Mark snmptoolctx unused in parse_authentication(..), parse_privacy(..), parse_context(..), and parse_user_security(..). Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Mon May 23 05:41:23 2016 (r300470) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Mon May 23 05:41:53 2016 (r300471) @@ -93,7 +93,7 @@ static char *snmp_oct2bits(uint32_t len, static char *snmp_bits2oct(char *str, struct asn_oid *oid); static int32_t parse_bits(struct snmp_value *value, char *string); -struct snmp_text_conv { +static struct snmp_text_conv { enum snmp_tc tc; const char *tc_str; int32_t len; @@ -158,7 +158,7 @@ snmp_oct2tc(enum snmp_tc tc, uint32_t le uint32_t tc_len; char * buf; - if (tc < 0 || tc > SNMP_UNKNOWN) + if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; if (text_convs[tc].len > 0) @@ -183,7 +183,7 @@ snmp_oct2tc(enum snmp_tc tc, uint32_t le char * snmp_tc2oid(enum snmp_tc tc, char *str, struct asn_oid *oid) { - if (tc < 0 || tc > SNMP_UNKNOWN) + if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; return (text_convs[tc].tc2oid(str, oid)); @@ -192,7 +192,7 @@ snmp_tc2oid(enum snmp_tc tc, char *str, int32_t snmp_tc2oct(enum snmp_tc tc, struct snmp_value *value, char *string) { - if (tc < 0 || tc > SNMP_UNKNOWN) + if (tc > SNMP_UNKNOWN) tc = SNMP_UNKNOWN; return (text_convs[tc].tc2oct(value, string)); @@ -929,12 +929,11 @@ snmp_bridgeid2oct(char *str, struct asn_ static int32_t parse_bridge_id(struct snmp_value *sv, char *string) { - char *ptr, *endptr; + char *endptr; int32_t i, saved_errno; uint32_t v; uint8_t bridge_id[SNMP_BRIDGEID_OCTETS]; - ptr = string; /* Read the priority. */ saved_errno = errno; errno = 0; @@ -1057,12 +1056,11 @@ snmp_bport_id2oct(char *str, struct asn_ static int32_t parse_bport_id(struct snmp_value *value, char *string) { - char *ptr, *endptr; + char *endptr; int saved_errno; uint32_t v; uint8_t bport_id[SNMP_BPORT_OCTETS]; - ptr = string; /* Read the priority. */ saved_errno = errno; errno = 0; @@ -1175,13 +1173,13 @@ snmp_oct2inetaddr(uint32_t len, char *oc } static char * -snmp_inetaddr2oct(char *str, struct asn_oid *oid) +snmp_inetaddr2oct(char *str __unused, struct asn_oid *oid __unused) { return (NULL); } static int32_t -parse_inetaddr(struct snmp_value *value, char *string) +parse_inetaddr(struct snmp_value *value __unused, char *string __unused) { return (-1); } Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c ============================================================================== --- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Mon May 23 05:41:23 2016 (r300470) +++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Mon May 23 05:41:53 2016 (r300471) @@ -256,14 +256,12 @@ add_filename(struct snmp_toolinfo *snmpt return (-1); } - if ((entry = malloc(sizeof(struct fname))) == NULL) { + if ((entry = calloc(1, sizeof(struct fname))) == NULL) { warnx("malloc() failed - %s", strerror(errno)); free(fstring); return (-1); } - memset(entry, 0, sizeof(struct fname)); - if (cut != NULL) asn_append_oid(&(entry->cut), cut); strlcpy(fstring, filename, strlen(filename) + 1); @@ -446,9 +444,10 @@ parse_flist(struct snmp_toolinfo *snmpto static int32_t parse_ascii(char *ascii, uint8_t *binstr, size_t binlen) { - int32_t alen, count, saved_errno, i; - uint32_t val; char dptr[3]; + size_t count; + int32_t alen, i, saved_errno; + uint32_t val; /* Filter 0x at the beginning */ if ((alen = strlen(ascii)) > 2 && ascii[0] == '0' && ascii[1] == 'x') @@ -483,7 +482,7 @@ parse_ascii(char *ascii, uint8_t *binstr * snmp_client structure. */ int32_t -parse_authentication(struct snmp_toolinfo *snmptoolctx, char *opt_arg) +parse_authentication(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) { int32_t count, subopt; char *val, *option; @@ -538,7 +537,7 @@ parse_authentication(struct snmp_toolinf } int32_t -parse_privacy(struct snmp_toolinfo *snmptoolctx, char *opt_arg) +parse_privacy(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) { int32_t count, subopt; char *val, *option; @@ -591,7 +590,7 @@ parse_privacy(struct snmp_toolinfo *snmp } int32_t -parse_context(struct snmp_toolinfo *snmptoolctx, char *opt_arg) +parse_context(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) { int32_t count, subopt; char *val, *option; @@ -633,7 +632,7 @@ parse_context(struct snmp_toolinfo *snmp } int32_t -parse_user_security(struct snmp_toolinfo *snmptoolctx, char *opt_arg) +parse_user_security(struct snmp_toolinfo *snmptoolctx __unused, char *opt_arg) { int32_t count, subopt, saved_errno; char *val, *option; @@ -1366,12 +1365,11 @@ snmp_object_add(struct snmp_toolinfo *sn return (-1); } - if ((obj = malloc(sizeof(struct snmp_object))) == NULL) { + if ((obj = calloc(1, sizeof(struct snmp_object))) == NULL) { syslog(LOG_ERR, "malloc() failed: %s", strerror(errno)); return (-1); } - memset(obj, 0, sizeof(struct snmp_object)); if (func(snmptoolctx, obj, string) < 0) { warnx("Invalid OID - %s", string); free(obj);