summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e60fc45)
raw | patch | inline | side by side (parent: e60fc45)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 17 Dec 2016 17:39:39 +0000 (18:39 +0100) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 17 Dec 2016 17:39:39 +0000 (18:39 +0100) |
We call strstripnewline on it, which expects a null-terminated string.
CID #158524
CID #158524
src/battery.c | patch | blob | history |
diff --git a/src/battery.c b/src/battery.c
index 5c02fee235c624fc9b556d8581b884ced17b1146..78e96b25314dd72052c536c18e2fbb02b3037c79 100644 (file)
--- a/src/battery.c
+++ b/src/battery.c
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));