svn commit: r274900 - head/usr.sbin/bsnmpd/modules/snmp_hostres

Dimitry Andric dim at FreeBSD.org
Sat Nov 22 23:50:20 UTC 2014


Author: dim
Date: Sat Nov 22 23:50:18 2014
New Revision: 274900
URL: https://svnweb.freebsd.org/changeset/base/274900

Log:
  Fix the following -Werror warnings from clang 3.5.0, while building
  bsnmpd's snmp_hostres module:
  
  usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c:204:20: error: absolute value function 'abs' given an argument of type 'const long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
          str[9] = (u_char)(abs(tm->tm_gmtoff) / 3600);
                            ^
  usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c:204:20: note: use function 'labs' instead
          str[9] = (u_char)(abs(tm->tm_gmtoff) / 3600);
                            ^~~
                            labs
  usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c:205:22: error: absolute value function 'abs' given an argument of type 'const long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
          str[10] = (u_char)((abs(tm->tm_gmtoff) % 3600) / 60);
                              ^
  usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c:205:22: note: use function 'labs' instead
          str[10] = (u_char)((abs(tm->tm_gmtoff) % 3600) / 60);
                              ^~~
                              labs
  
  Since tm::tm_gmtoff is a long, use labs(3) instead.
  
  MFC after:	3 days

Modified:
  head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c

Modified: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c
==============================================================================
--- head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c	Sat Nov 22 23:28:41 2014	(r274899)
+++ head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c	Sat Nov 22 23:50:18 2014	(r274900)
@@ -201,8 +201,8 @@ make_date_time(u_char *str, const struct
 	else
 		str[8] = '+';
 
-	str[9] = (u_char)(abs(tm->tm_gmtoff) / 3600);
-	str[10] = (u_char)((abs(tm->tm_gmtoff) % 3600) / 60);
+	str[9] = (u_char)(labs(tm->tm_gmtoff) / 3600);
+	str[10] = (u_char)((labs(tm->tm_gmtoff) % 3600) / 60);
 
 	return (11);
 }


More information about the svn-src-all mailing list