[collectd] [PATCH 2/2] snmp.c: compilation fixes for AIX

Aurelien Reynaud collectd at wattapower.net
Wed May 12 11:55:05 CEST 2010


The C and C++ standards allows the character type char to be signed or
unsigned, depending on the platform and compiler. Most systems,
including x86 GNU/Linux and Microsoft Windows, use signed char, but
those based on PowerPC and ARM processors typically use unsigned char.

This patch fixes a "comparison is always true" warning on AIX (powerpc)
which leads the compilation to abort because of the -Werror flag.

Being unsigned by default, a char is always >0.

Signed-off-by: Aurelien Reynaud <collectd at wattapower.net>
---
 src/snmp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/snmp.c b/src/snmp.c
index fdb7c65..6ac14e6 100644
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -952,7 +952,7 @@ static int csnmp_strvbcopy (char *dst, /* {{{ */
   for (i = 0; i < num_chars; i++)
   {
     /* Check for control characters. */
-    if ((src[i] >= 0) && (src[i] < 32))
+    if ((unsigned char)src[i] < 32)
       return (csnmp_strvbcopy_hexstring (dst, vb, dst_size));
     dst[i] = src[i];
   }
-- 
1.7.1




More information about the collectd mailing list