ssnprintf(filename, sizeof(filename), "%s/%s/%s", dir, power_supply,
basename);
- status = (int)read_file_contents(filename, buffer, buffer_size);
+ status = (int)read_file_contents(filename, buffer, buffer_size - 1);
if (status < 0)
return status;
+ buffer[status] = '\0';
+
strstripnewline(buffer);
return 0;
} /* }}} int sysfs_file_to_buffer */
char const *power_supply, char const *basename,
gauge_t *ret_value) {
int status;
- char buffer[32] = "";
+ char buffer[32];
status =
sysfs_file_to_buffer(dir, power_supply, basename, buffer, sizeof(buffer));