[hackers] [slstatus] battery: Remove unnecessary defines for paths || Aaron Marcher

From: <git_AT_suckless.org>
Date: Fri, 6 Jul 2018 23:55:50 +0200 (CEST)

commit 609ef3aa1f6c0a47822d425dc6bb0744042ca038
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Fri Jul 6 23:55:18 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Fri Jul 6 23:55:18 2018 +0200

    battery: Remove unnecessary defines for paths

diff --git a/components/battery.c b/components/battery.c
index 99e09d5..82e0baf 100644
--- a/components/battery.c
+++ b/components/battery.c
_AT_@ -8,11 +8,6 @@
         #include <limits.h>
         #include <unistd.h>
 
- #define CHARGE_NOW "/sys/class/power_supply/%s/charge_now"
- #define ENERGY_NOW "/sys/class/power_supply/%s/energy_now"
- #define CURRENT_NOW "/sys/class/power_supply/%s/current_now"
- #define POWER_NOW "/sys/class/power_supply/%s/power_now"
-
         static const char *
         pick(const char *bat, const char *f1, const char *f2, char *path,
              size_t length)
_AT_@ -94,13 +89,16 @@
                         return NULL;
                 }
 
- if (!pick(bat, CHARGE_NOW, ENERGY_NOW, path, sizeof(path)) ||
+ if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
+ "/sys/class/power_supply/%s/energy_now",
+ path, sizeof(path)) ||
                     pscanf(path, "%d", &charge_now) < 0) {
                         return NULL;
                 }
 
                 if (!strcmp(state, "Discharging")) {
- if (!pick(bat, CURRENT_NOW, POWER_NOW, path,
+ if (!pick(bat, "/sys/class/power_supply/%s/current_now",
+ "/sys/class/power_supply/%s/power_now", path,
                                   sizeof(path)) ||
                             pscanf(path, "%d", &current_now) < 0) {
                                 return NULL;
Received on Fri Jul 06 2018 - 23:55:50 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 07 2018 - 00:00:27 CEST