From 8aff3bdeeb6e29663099764dee4220098d5b83d9 Mon Sep 17 00:00:00 2001 From: ngie Date: Sat, 7 Jan 2017 08:46:16 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.freebsd.org/base/stable/10@311595 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c | 27 +++++++++-------- usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c | 22 +++++++------- .../bsnmpd/tools/libbsnmptools/bsnmptools.c | 29 ++++++++----------- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c index 2a626393a..2a214aa16 100644 --- a/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c +++ b/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c @@ -394,7 +394,7 @@ snmptool_get(struct snmp_toolinfo *snmptoolctx) 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 *snmptoolctx) 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 *value, char *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 *val) 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, char *val) 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, char *val) 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 snmp_value *snmp_val) 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 snmp_value *snmp_val) * 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 *snmptoolctx) 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; } diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c index 32ba21616..dcc4361d2 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c @@ -268,7 +268,7 @@ parse_octetstring(struct snmp_value *value, char *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, char *val) 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_oid *oid) 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, char *val) 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 asn_oid *oid) 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 *val) } 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, char *string) 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, char *string) 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 *octets, char *buf) } 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 *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, char *string) 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); } diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c index 3ad5a63cb..36b991758 100644 --- a/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c +++ b/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c @@ -177,7 +177,7 @@ snmptool_init(struct snmp_toolinfo *snmptoolctx) 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 *snmptoolctx, const char *filename, } 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 *snmptoolctx __unused, char *opt_arg) 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 *snmptoolctx __unused, char *opt_arg) 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_oid *oid) 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_oid *oid) 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 asn_oid *oid) 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); } -- 2.45.0