diff options
author | Tommie Gannert <tommie@gannert.se> | 2016-08-16 09:18:05 +0100 |
---|---|---|
committer | Tommie Gannert <tommie@gannert.se> | 2016-08-22 21:18:31 +0100 |
commit | ac8998ef03374abca56da9929812c6fcba936031 (patch) | |
tree | 04a7250ee127813fca75e4b42e38bdffe61bc3f5 | |
parent | 15de209cbaee6827f061e8d2788c9db232012c6b (diff) |
Match trailing equal sign in slurp_battery_info.
Should make it more resilient to future ambiguities in uevent.
-rw-r--r-- | src/print_battery_info.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/print_battery_info.c b/src/print_battery_info.c index c20e87e..27473a2 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -65,21 +65,21 @@ static bool slurp_battery_info(struct battery_info *batt_info, yajl_gen json_gen if (*walk != '=') continue; - if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_NOW")) { + if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_NOW=")) { watt_as_unit = true; batt_info->remaining = atoi(walk + 1); - } else if (BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_NOW")) { + } else if (BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_NOW=")) { watt_as_unit = false; batt_info->remaining = atoi(walk + 1); - } else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW")) + } else if (BEGINS_WITH(last, "POWER_SUPPLY_CURRENT_NOW=")) batt_info->present_rate = abs(atoi(walk + 1)); - else if (BEGINS_WITH(last, "POWER_SUPPLY_VOLTAGE_NOW")) + else if (BEGINS_WITH(last, "POWER_SUPPLY_VOLTAGE_NOW=")) voltage = abs(atoi(walk + 1)); /* on some systems POWER_SUPPLY_POWER_NOW does not exist, but actually * it is the same as POWER_SUPPLY_CURRENT_NOW but with μWh as * unit instead of μAh. We will calculate it as we need it * later. */ - else if (BEGINS_WITH(last, "POWER_SUPPLY_POWER_NOW")) + else if (BEGINS_WITH(last, "POWER_SUPPLY_POWER_NOW=")) batt_info->present_rate = abs(atoi(walk + 1)); else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=Charging")) batt_info->status = CS_CHARGING; @@ -89,11 +89,11 @@ static bool slurp_battery_info(struct battery_info *batt_info, yajl_gen json_gen batt_info->status = CS_DISCHARGING; else if (BEGINS_WITH(last, "POWER_SUPPLY_STATUS=")) batt_info->status = CS_UNKNOWN; - else if (BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN") || - BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN")) + else if (BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN=") || + BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN=")) batt_info->full_design = atoi(walk + 1); - else if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL") || - BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL")) + else if (BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL=") || + BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL=")) batt_info->full_last = atoi(walk + 1); } |