{
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))
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 */
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)
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)