diff options
author | Alexander Monakov <amonakov@ispras.ru> | 2014-12-18 18:23:25 +0300 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2014-12-22 09:19:40 +0100 |
commit | 05273b03fda3824bc640319999343040fca81635 (patch) | |
tree | 517cf8ea4fcd1aa42a2b2ba30e5033318e4d7c85 /src/print_battery_info.c | |
parent | 3818dabcebea7f98e3dfdfbe5be42374bb60cf88 (diff) |
Avoid use of uninitialized variable in print_battery_info
The boolean flag 'watt_as_unit' may be used without being initialized if the
configured battery path does not contain expected statistics (for example if
it is misconfigured and points to AC adapter info or simply an unrelated file).
Even though it does not cause ill effects, it causes a warning (true positive)
when running i3status under Valgrind. Initialize the variable to make code
well-defined.
Diffstat (limited to 'src/print_battery_info.c')
-rw-r--r-- | src/print_battery_info.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c index 28b94ec..0df9b72 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -44,7 +44,7 @@ void print_battery_info(yajl_gen json_gen, char *buffer, int number, const char char consumptionbuf[256]; const char *walk, *last; char *outwalk = buffer; - bool watt_as_unit; + bool watt_as_unit = false; bool colorful_output = false; int full_design = -1, remaining = -1, |