Vibhav Pant (@vibhavp) commented about dlls/ntdll/unix/system.c:
- bat->full_charge_capacity = get_sys_int(path, "energy_full");
- bat->capacity_now = get_sys_int(path, "energy_now");
- bat->rate_now = get_sys_int(path, "power_now");
- bat->power_unit = BATTERY_UNIT_ENERGY;
- if (!bat->full_charge_capacity || !bat->capacity_now)
- {
bat->full_charge_capacity = get_sys_int(path, "charge_full");bat->capacity_now = get_sys_int(path, "charge_now");bat->voltage_now = get_sys_int(path, "voltage_now");bat->rate_now = get_sys_int(path, "current_now");bat->power_unit = BATTERY_UNIT_CHARGE;if (!bat->full_charge_capacity || !bat->capacity_now || !bat->voltage_now)bat->power_unit = BATTERY_UNIT_UNKNOWN;- }
It would improve readability if `full_charge_capacity`, `capacity_now` and `rate_now` in `linux_battery` were instead replaced with an inline `union` type, something like
```c union { struct { int charge_full_uah; int charge_now_uah; int current_now_ua; } charge; struct { int energy_full_uwh; int energy_now_uwh; int power_now_uw; } energy; } capacity_now; ```
With `power_unit` as the tag. The `fill_battery_state` code would also be much clearer as a result.