svn commit: r298750 - head/usr.sbin/bsnmpd/tools/libbsnmptools
Garrett Cooper
ngie at FreeBSD.org
Thu Apr 28 17:57:18 UTC 2016
Author: ngie
Date: Thu Apr 28 17:57:17 2016
New Revision: 298750
URL: https://svnweb.freebsd.org/changeset/base/298750
Log:
Use a better idiom for finding UTC prefixed timezones
Instead of copy-pasting the string literal for "UTC" 3 times and using
strlen, use a static char[3] buffer and sizeof(..).
MFC after: 3 days
X-MFC with: r298507
Submitted by: kib
Sponsored by: EMC / Isilon Storage Division
Modified:
head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
Modified: head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c
==============================================================================
--- head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Thu Apr 28 17:50:16 2016 (r298749)
+++ head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptc.c Thu Apr 28 17:57:17 2016 (r298750)
@@ -338,8 +338,9 @@ static char *
snmp_date2asn_oid(char *str, struct asn_oid *oid)
{
char *endptr, *ptr;
- uint32_t v;
+ static const char UTC[3] = "UTC";
int32_t saved_errno;
+ uint32_t v;
if (snmp_suboid_append(oid, (asn_subid_t) SNMP_DATETIME_OCTETS) < 0)
return (NULL);
@@ -440,8 +441,8 @@ snmp_date2asn_oid(char *str, struct asn_
/* 'UTC' - optional */
ptr = endptr + 1;
- if (strncmp(ptr, "UTC", strlen("UTC")) == 0)
- ptr += strlen("UTC");
+ if (strncmp(ptr, UTC, sizeof(UTC)) == 0)
+ ptr += sizeof(UTC);
/* '+/-' */
if (*ptr == '-' || *ptr == '+') {
More information about the svn-src-all
mailing list