svn commit: r311595 - in stable/10/usr.sbin/bsnmpd/tools: bsnmptools libbsnmptools
Ngie Cooper
ngie at FreeBSD.org
Sat Jan 7 08:46:17 UTC 2017
Author: ngie
Date: Sat Jan 7 08:46:16 2017
New Revision: 311595
URL: https://svnweb.freebsd.org/changeset/base/311595
Log:
MFC r310497:
Warning message cleanup
- Use warn instead of warnx + strerror(errno)
- Remove unnecessary trailing newline from a warnx call
- Add missing spaces following "," in syslog and warn* calls
Modified:
stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
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/bsnmptools/bsnmpget.c
==============================================================================
--- stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sat Jan 7 08:44:43 2017 (r311594)
+++ stable/10/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sat Jan 7 08:46:16 2017 (r311595)
@@ -394,7 +394,7 @@ snmptool_get(struct snmp_toolinfo *snmpt
GET_NONREP(snmptoolctx));
if (snmp_dialog(&req, &resp) == -1) {
- warnx("Snmp dialog - %s", strerror(errno));
+ warn("Snmp dialog");
break;
}
@@ -521,7 +521,7 @@ snmptool_walk(struct snmp_toolinfo *snmp
snmp_pdu_free(&resp);
} else
- warnx("Snmp dialog - %s", strerror(errno));
+ warn("Snmp dialog");
}
if (snmp_object_remove(snmptoolctx, &root) < 0) {
@@ -554,8 +554,7 @@ parse_oid_numeric(struct snmp_value *val
errno = 0;
suboid = strtoul(val, &endptr, 10);
if (errno != 0) {
- warnx("Value %s not supported - %s", val,
- strerror(errno));
+ warn("Value %s not supported", val);
errno = saved_errno;
return (-1);
}
@@ -634,7 +633,7 @@ parse_int(struct snmp_value *value, char
v = strtol(val, &endptr, 10);
if (errno != 0) {
- warnx("Value %s not supported - %s", val, strerror(errno));
+ warn("Value %s not supported", val);
errno = saved_errno;
return (-1);
}
@@ -682,7 +681,7 @@ parse_uint(struct snmp_value *value, cha
v = strtoul(val, &endptr, 10);
if (errno != 0) {
- warnx("Value %s not supported - %s", val, strerror(errno));
+ warn("Value %s not supported", val);
errno = saved_errno;
return (-1);
}
@@ -736,7 +735,7 @@ parse_uint64(struct snmp_value *value, c
v = strtoull(val, &endptr, 10);
if (errno != 0) {
- warnx("Value %s not supported - %s", val, strerror(errno));
+ warnx("Value %s not supported", val);
errno = saved_errno;
return (-1);
}
@@ -821,7 +820,7 @@ parse_pair_numoid_val(char *str, struct
break;
if (ptr[cnt] != '\0') {
- warnx("Value string too long - %s",ptr);
+ warnx("Value string too long - %s", ptr);
return (-1);
}
@@ -830,7 +829,7 @@ parse_pair_numoid_val(char *str, struct
* to know syntax to check value boundaries.
*/
if (snmp_parse_numoid(oid_str, &(snmp_val->var)) < 0) {
- warnx("Error parsing OID %s",oid_str);
+ warnx("Error parsing OID %s", oid_str);
return (-1);
}
@@ -955,7 +954,7 @@ static int32_t
add_octstring_syntax(struct snmp_value *dst, struct snmp_value *src)
{
if (src->v.octetstring.len > ASN_MAXOCTETSTRING) {
- warnx("OctetString len too big - %u",src->v.octetstring.len);
+ warnx("OctetString len too big - %u", src->v.octetstring.len);
return (-1);
}
@@ -1083,7 +1082,7 @@ snmptool_set(struct snmp_toolinfo *snmpt
while ((snmp_pdu_add_bindings(snmptoolctx, snmpset_verify_vbind,
snmpset_add_vbind, &req, SNMP_MAX_BINDINGS)) > 0) {
if (snmp_dialog(&req, &resp)) {
- warnx("Snmp dialog - %s", strerror(errno));
+ warn("Snmp dialog");
break;
}
@@ -1228,7 +1227,7 @@ main(int argc, char ** argv)
}
if (snmp_open(NULL, NULL, NULL, NULL)) {
- warnx("Failed to open snmp session: %s.", strerror(errno));
+ warn("Failed to open snmp session");
snmp_tool_freeall(&snmptoolctx);
exit(1);
}
@@ -1238,7 +1237,7 @@ main(int argc, char ** argv)
if (ISSET_EDISCOVER(&snmptoolctx) &&
snmp_discover_engine(snmptoolctx.passwd) < 0) {
- warnx("Unknown SNMP Engine ID: %s.", strerror(errno));
+ warn("Unknown SNMP Engine ID");
rc = 1;
goto cleanup;
}
@@ -1254,7 +1253,7 @@ main(int argc, char ** argv)
snmp_get_local_keys(&snmp_client.user,
snmp_client.engine.engine_id,
snmp_client.engine.engine_len) != SNMP_CODE_OK) {
- warnx("Failed to get keys: %s.", strerror(errno));
+ warn("Failed to get keys");
rc = 1;
goto cleanup;
}
Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
==============================================================================
--- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Jan 7 08:44:43 2017 (r311594)
+++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Sat Jan 7 08:46:16 2017 (r311595)
@@ -268,7 +268,7 @@ parse_octetstring(struct snmp_value *val
if ((value->v.octetstring.octets = malloc(len)) == NULL) {
value->v.octetstring.len = 0;
- syslog(LOG_ERR,"malloc failed: %s", strerror(errno));
+ syslog(LOG_ERR, "malloc failed: %s", strerror(errno));
return (-1);
}
@@ -570,7 +570,7 @@ parse_dateandtime(struct snmp_value *sv,
date[10] = v;
if ((sv->v.octetstring.octets = malloc(SNMP_DATETIME_OCTETS)) == NULL) {
- warnx("malloc() failed - %s", strerror(errno));
+ warn("malloc() failed");
return (-1);
}
@@ -626,7 +626,7 @@ snmp_addr2asn_oid(char *str, struct asn_
return (NULL);
}
if (*endptr != ':') {
- warnx("Failed adding oid - %s",str);
+ warnx("Failed adding oid - %s", str);
return (NULL);
}
if (snmp_suboid_append(oid, (asn_subid_t) v) < 0)
@@ -679,7 +679,7 @@ parse_physaddress(struct snmp_value *sv,
phys_addr[5] = v;
if ((sv->v.octetstring.octets = malloc(SNMP_PHYSADDR_OCTETS)) == NULL) {
- syslog(LOG_ERR,"malloc failed: %s", strerror(errno));
+ syslog(LOG_ERR, "malloc failed: %s", strerror(errno));
return (-1);
}
@@ -743,7 +743,7 @@ snmp_ntp_ts2asn_oid(char *str, struct as
errno = saved_errno;
if (*endptr != '.') {
- warnx("Failed adding oid - %s",str);
+ warnx("Failed adding oid - %s", str);
return (NULL);
}
@@ -824,7 +824,7 @@ parse_ntp_ts(struct snmp_value *sv, char
}
if ((sv->v.octetstring.octets = malloc(SNMP_NTP_TS_OCTETS)) == NULL) {
- syslog(LOG_ERR,"malloc failed: %s", strerror(errno));
+ syslog(LOG_ERR, "malloc failed: %s", strerror(errno));
return (-1);
}
@@ -987,7 +987,7 @@ parse_bridge_id(struct snmp_value *sv, c
bridge_id[7] = v;
if ((sv->v.octetstring.octets = malloc(SNMP_BRIDGEID_OCTETS)) == NULL) {
- syslog(LOG_ERR,"malloc failed: %s", strerror(errno));
+ syslog(LOG_ERR, "malloc failed: %s", strerror(errno));
return (-1);
}
@@ -1098,7 +1098,7 @@ parse_bport_id(struct snmp_value *value,
bport_id[1] = v;
if ((value->v.octetstring.octets = malloc(SNMP_BPORT_OCTETS)) == NULL) {
- syslog(LOG_ERR,"malloc failed: %s", strerror(errno));
+ syslog(LOG_ERR, "malloc failed: %s", strerror(errno));
return (-1);
}
@@ -1178,7 +1178,7 @@ snmp_oct2inetaddr(uint32_t len, char *oc
}
if (inet_ntop(af, ip, buf, SNMP_INADDRS_STRSZ) == NULL) {
- warnx("inet_ntop failed - %s", strerror(errno));
+ warn("inet_ntop failed");
return (NULL);
}
@@ -1230,7 +1230,7 @@ snmp_bits2oct(char *str, struct asn_oid
v = strtoull(str, &endptr, 16);
if (errno != 0) {
- warnx("Bad BITS value %s - %s", str, strerror(errno));
+ warn("Bad BITS value %s", str);
errno = saved_errno;
return (NULL);
}
@@ -1270,7 +1270,7 @@ parse_bits(struct snmp_value *value, cha
v = strtoull(string, &endptr, 16);
if (errno != 0) {
- warnx("Bad BITS value %s - %s", string, strerror(errno));
+ warn("Bad BITS value %s", string);
errno = saved_errno;
return (-1);
}
Modified: stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Jan 7 08:44:43 2017 (r311594)
+++ stable/10/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sat Jan 7 08:46:16 2017 (r311595)
@@ -177,7 +177,7 @@ snmptool_init(struct snmp_toolinfo *snmp
if ((slen = strlen(str)) > MAXSTR)
slen = MAXSTR - 1;
if ((snmptoolctx->passwd = malloc(slen + 1)) == NULL) {
- warnx("malloc() failed - %s", strerror(errno));
+ warn("malloc() failed");
return (-1);
}
if (slen > 0)
@@ -252,12 +252,12 @@ add_filename(struct snmp_toolinfo *snmpt
}
if ((fstring = strdup(filename)) == NULL) {
- warnx("strdup() failed - %s", strerror(errno));
+ warn("strdup() failed");
return (-1);
}
if ((entry = calloc(1, sizeof(struct fname))) == NULL) {
- warnx("calloc() failed - %s", strerror(errno));
+ warn("calloc() failed");
free(fstring);
return (-1);
}
@@ -668,8 +668,7 @@ parse_user_security(struct snmp_toolinfo
errno = 0;
snmp_client.engine.engine_boots = strtoul(val, NULL, 10);
if (errno != 0) {
- warnx("Bad 'engine-boots' value %s - %s", val,
- strerror(errno));
+ warn("Bad 'engine-boots' value %s", val);
errno = saved_errno;
return (-1);
}
@@ -684,8 +683,7 @@ parse_user_security(struct snmp_toolinfo
errno = 0;
snmp_client.engine.engine_time = strtoul(val, NULL, 10);
if (errno != 0) {
- warnx("Bad 'engine-time' value %s - %s", val,
- strerror(errno));
+ warn("Bad 'engine-time' value %s", val);
errno = saved_errno;
return (-1);
}
@@ -819,7 +817,7 @@ parse_timeout(char *opt_arg)
v = strtol(opt_arg, NULL, 10);
if (errno != 0) {
- warnx( "Error parsing timeout value - %s", strerror(errno));
+ warn("Error parsing timeout value");
errno = saved_errno;
return (-1);
}
@@ -842,7 +840,7 @@ parse_retry(char *opt_arg)
v = strtoul(opt_arg, NULL, 10);
if (errno != 0) {
- warnx("Error parsing retries count - %s", strerror(errno));
+ warn("Error parsing retries count");
errno = saved_errno;
return (-1);
}
@@ -865,7 +863,7 @@ parse_version(char *opt_arg)
v = strtoul(opt_arg, NULL, 10);
if (errno != 0) {
- warnx("Error parsing version - %s", strerror(errno));
+ warn("Error parsing version");
errno = saved_errno;
return (-1);
}
@@ -917,7 +915,7 @@ parse_buflen(char *opt_arg)
size = strtoul(opt_arg, NULL, 10);
if (errno != 0) {
- warnx("Error parsing buffer size - %s", strerror(errno));
+ warn("Error parsing buffer size");
errno = saved_errno;
return (-1);
}
@@ -1040,8 +1038,7 @@ snmp_int2asn_oid(char *str, struct asn_o
v = strtol(str, &endptr, 10);
if (errno != 0) {
- warnx("Integer value %s not supported - %s", str,
- strerror(errno));
+ warn("Integer value %s not supported", str);
errno = saved_errno;
return (NULL);
}
@@ -1121,8 +1118,7 @@ snmp_uint2asn_oid(char *str, struct asn_
v = strtoul(str, &endptr, 10);
if (errno != 0) {
- warnx("Integer value %s not supported - %s\n", str,
- strerror(errno));
+ warn("Integer value %s not supported", str);
errno = saved_errno;
return (NULL);
}
@@ -1146,8 +1142,7 @@ snmp_cnt64_2asn_oid(char *str, struct as
v = strtoull(str, &endptr, 10);
if (errno != 0) {
- warnx("Integer value %s not supported - %s", str,
- strerror(errno));
+ warn("Integer value %s not supported", str);
errno = saved_errno;
return (NULL);
}
More information about the svn-src-stable
mailing list