svn commit: r300558 - stable/9/usr.sbin/bsnmpd/tools/libbsnmptools
Garrett Cooper
ngie at FreeBSD.org
Tue May 24 04:18:17 UTC 2016
Author: ngie
Date: Tue May 24 04:18:15 2016
New Revision: 300558
URL: https://svnweb.freebsd.org/changeset/base/300558
Log:
MFstable/10 r300471:
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/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Directory Properties:
stable/9/ (props changed)
stable/9/usr.sbin/ (props changed)
stable/9/usr.sbin/bsnmpd/ (props changed)
Modified: stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
==============================================================================
--- stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Tue May 24 03:15:46 2016 (r300557)
+++ stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Tue May 24 04:18:15 2016 (r300558)
@@ -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/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Tue May 24 03:15:46 2016 (r300557)
+++ stable/9/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Tue May 24 04:18:15 2016 (r300558)
@@ -255,14 +255,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);
@@ -445,9 +443,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 beggining */
if ((alen = strlen(ascii)) > 2 && ascii[0] == '0' && ascii[1] == 'x')
@@ -482,7 +481,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;
@@ -537,7 +536,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;
@@ -590,7 +589,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;
@@ -632,7 +631,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;
@@ -1365,12 +1364,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);
More information about the svn-src-stable-9
mailing list