src/utils_dns.c: Fix version information for __NAMESER >= 19961001.
[collectd.git] / src / battery.c
index 2e27e60..badd8e7 100644 (file)
@@ -77,7 +77,7 @@ static int battery_init (void)
        {
                len = snprintf (filename, sizeof (filename), battery_pmu_file, battery_pmu_num);
 
-               if ((len >= sizeof (filename)) || (len < 0))
+               if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
                        break;
 
                if (access (filename, R_OK))
@@ -98,9 +98,9 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl
        vl.values = values;
        vl.values_len = 1;
        vl.time = time (NULL);
-       strcpy (vl.host, hostname_g);
-       strcpy (vl.plugin, "battery");
-       strcpy (vl.plugin_instance, plugin_instance);
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "battery", sizeof (vl.plugin));
+       sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
 
        plugin_dispatch_values (type, &vl);
 } /* void battery_submit */
@@ -360,11 +360,11 @@ static int battery_read (void)
                double *valptr = NULL;
 
                len = snprintf (filename, sizeof (filename), battery_pmu_file, i);
-               if ((len >= sizeof (filename)) || (len < 0))
+               if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
                        continue;
 
                len = snprintf (batnum_str, sizeof (batnum_str), "%i", i);
-               if ((len >= sizeof (batnum_str)) || (len < 0))
+               if ((len < 0) || ((unsigned int)len >= sizeof (batnum_str)))
                        continue;
 
                if ((fh = fopen (filename, "r")) == NULL)
@@ -438,7 +438,7 @@ static int battery_read (void)
                        len = snprintf (filename, sizeof (filename),
                                        "/proc/acpi/battery/%s/state",
                                        ent->d_name);
-                       if ((len >= sizeof (filename)) || (len < 0))
+                       if ((len < 0) || ((unsigned int)len >= sizeof (filename)))
                                continue;
 
                        if ((fh = fopen (filename, "r")) == NULL)