X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fbattery.c;h=f8e67a41aa1735748980f934c651a001747cb1ab;hb=5f9ec13b946733ff4e1edf2d8e3b7a22311dd894;hp=0522015237d586897327b916f56d9602b1352223;hpb=2354eda94fa44c8bcb8e39b24b117e7937110224;p=collectd.git diff --git a/src/battery.c b/src/battery.c index 05220152..f8e67a41 100644 --- a/src/battery.c +++ b/src/battery.c @@ -75,7 +75,7 @@ static int battery_init (void) for (battery_pmu_num = 0; ; battery_pmu_num++) { - len = snprintf (filename, sizeof (filename), battery_pmu_file, battery_pmu_num); + len = ssnprintf (filename, sizeof (filename), battery_pmu_file, battery_pmu_num); if ((len < 0) || ((unsigned int)len >= sizeof (filename))) break; @@ -100,8 +100,8 @@ static void battery_submit (const char *plugin_instance, const char *type, doubl vl.time = time (NULL); strcpy (vl.host, hostname_g); strcpy (vl.plugin, "battery"); - strncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); - strncpy (vl.type, type, sizeof (vl.type)); + sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, type, sizeof (vl.type)); plugin_dispatch_values (&vl); } /* void battery_submit */ @@ -360,11 +360,11 @@ static int battery_read (void) double charge = INVALID_VALUE; double *valptr = NULL; - len = snprintf (filename, sizeof (filename), battery_pmu_file, i); + len = ssnprintf (filename, sizeof (filename), battery_pmu_file, i); if ((len < 0) || ((unsigned int)len >= sizeof (filename))) continue; - len = snprintf (batnum_str, sizeof (batnum_str), "%i", i); + len = ssnprintf (batnum_str, sizeof (batnum_str), "%i", i); if ((len < 0) || ((unsigned int)len >= sizeof (batnum_str))) continue; @@ -436,7 +436,7 @@ static int battery_read (void) if (ent->d_name[0] == '.') continue; - len = snprintf (filename, sizeof (filename), + len = ssnprintf (filename, sizeof (filename), "/proc/acpi/battery/%s/state", ent->d_name); if ((len < 0) || ((unsigned int)len >= sizeof (filename)))