summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-11-25 12:46:00 +0100
committerChristian Göttsche <cgzones@googlemail.com>2020-11-25 12:47:07 +0100
commit601ad61e7ddd5a79a0c650ff617b617470fafe07 (patch)
tree03734ee31c6dac9009cefe3286beaebbab43f7b6
parenta3221f367779288090715f4098d9a874cd113ad3 (diff)
Unify naming of first argument of Platform_getBattery
Use percent throughout
-rw-r--r--darwin/Platform.c6
-rw-r--r--dragonflybsd/Platform.c6
-rw-r--r--dragonflybsd/Platform.h2
-rw-r--r--freebsd/Platform.c6
-rw-r--r--freebsd/Platform.h2
-rw-r--r--linux/Platform.c30
-rw-r--r--openbsd/Platform.c8
-rw-r--r--openbsd/Platform.h2
-rw-r--r--solaris/Platform.c4
-rw-r--r--solaris/Platform.h2
-rw-r--r--unsupported/Platform.c4
11 files changed, 36 insertions, 36 deletions
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 09fec45a..e24b67bc 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -355,10 +355,10 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
return false;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
CFTypeRef power_sources = IOPSCopyPowerSourcesInfo();
- *level = NAN;
+ *percent = NAN;
*isOnAC = AC_ERROR;
if (NULL == power_sources)
@@ -410,7 +410,7 @@ void Platform_getBattery(double* level, ACPresence* isOnAC) {
CFNumberGetValue(CFDictionaryGetValue(battery, CFSTR(kIOPSMaxCapacityKey)),
kCFNumberDoubleType, &max);
- *level = (current * 100.0) / max;
+ *percent = (current * 100.0) / max;
CFRelease(battery);
}
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index 6ca576fe..40a73487 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -244,13 +244,13 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
return false;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
int life;
size_t life_len = sizeof(life);
if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1)
- *level = NAN;
+ *percent = NAN;
else
- *level = life;
+ *percent = life;
int acline;
size_t acline_len = sizeof(acline);
diff --git a/dragonflybsd/Platform.h b/dragonflybsd/Platform.h
index a05eb641..5456539e 100644
--- a/dragonflybsd/Platform.h
+++ b/dragonflybsd/Platform.h
@@ -60,6 +60,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted);
-void Platform_getBattery(double* level, ACPresence* isOnAC);
+void Platform_getBattery(double* percent, ACPresence* isOnAC);
#endif
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 89430814..506cafb4 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -357,13 +357,13 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
return true;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
int life;
size_t life_len = sizeof(life);
if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1)
- *level = NAN;
+ *percent = NAN;
else
- *level = life;
+ *percent = life;
int acline;
size_t acline_len = sizeof(acline);
diff --git a/freebsd/Platform.h b/freebsd/Platform.h
index 983f943a..5b3b0195 100644
--- a/freebsd/Platform.h
+++ b/freebsd/Platform.h
@@ -66,6 +66,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted);
-void Platform_getBattery(double* level, ACPresence* isOnAC);
+void Platform_getBattery(double* percent, ACPresence* isOnAC);
#endif
diff --git a/linux/Platform.c b/linux/Platform.c
index aab2f45e..82354717 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -110,7 +110,7 @@ const unsigned int Platform_numberOfSignals = ARRAYSIZE(Platform_signals);
static enum { BAT_PROC, BAT_SYS, BAT_ERR } Platform_Battery_method = BAT_PROC;
static time_t Platform_Battery_cacheTime;
-static double Platform_Battery_cacheLevel = NAN;
+static double Platform_Battery_cachePercent = NAN;
static ACPresence Platform_Battery_cacheIsOnAC;
void Platform_init(void) {
@@ -708,9 +708,9 @@ static double Platform_Battery_getProcBatInfo(void) {
return totalRemain * 100.0 / (double) totalFull;
}
-static void Platform_Battery_getProcData(double* level, ACPresence* isOnAC) {
+static void Platform_Battery_getProcData(double* percent, ACPresence* isOnAC) {
*isOnAC = procAcpiCheck();
- *level = AC_ERROR != *isOnAC ? Platform_Battery_getProcBatInfo() : NAN;
+ *percent = AC_ERROR != *isOnAC ? Platform_Battery_getProcBatInfo() : NAN;
}
// ----------------------------------------
@@ -739,9 +739,9 @@ static inline ssize_t xread(int fd, void* buf, size_t count) {
}
}
-static void Platform_Battery_getSysData(double* level, ACPresence* isOnAC) {
+static void Platform_Battery_getSysData(double* percent, ACPresence* isOnAC) {
- *level = NAN;
+ *percent = NAN;
*isOnAC = AC_ERROR;
DIR* dir = opendir(SYS_POWERSUPPLY_DIR);
@@ -857,35 +857,35 @@ static void Platform_Battery_getSysData(double* level, ACPresence* isOnAC) {
}
closedir(dir);
- *level = totalFull > 0 ? ((double) totalRemain * 100.0) / (double) totalFull : NAN;
+ *percent = totalFull > 0 ? ((double) totalRemain * 100.0) / (double) totalFull : NAN;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
time_t now = time(NULL);
// update battery reading is slow. Update it each 10 seconds only.
if (now < Platform_Battery_cacheTime + 10) {
- *level = Platform_Battery_cacheLevel;
+ *percent = Platform_Battery_cachePercent;
*isOnAC = Platform_Battery_cacheIsOnAC;
return;
}
if (Platform_Battery_method == BAT_PROC) {
- Platform_Battery_getProcData(level, isOnAC);
- if (isnan(*level))
+ Platform_Battery_getProcData(percent, isOnAC);
+ if (isnan(*percent))
Platform_Battery_method = BAT_SYS;
}
if (Platform_Battery_method == BAT_SYS) {
- Platform_Battery_getSysData(level, isOnAC);
- if (isnan(*level))
+ Platform_Battery_getSysData(percent, isOnAC);
+ if (isnan(*percent))
Platform_Battery_method = BAT_ERR;
}
if (Platform_Battery_method == BAT_ERR) {
- *level = NAN;
+ *percent = NAN;
*isOnAC = AC_ERROR;
} else {
- *level = CLAMP(*level, 0.0, 100.0);
+ *percent = CLAMP(*percent, 0.0, 100.0);
}
- Platform_Battery_cacheLevel = *level;
+ Platform_Battery_cachePercent = *percent;
Platform_Battery_cacheIsOnAC = *isOnAC;
Platform_Battery_cacheTime = now;
}
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index 550e2584..38fbab67 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -349,7 +349,7 @@ static bool findDevice(const char* name, int* mib, struct sensordev* snsrdev, si
}
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
static int mib[] = {CTL_HW, HW_SENSORS, 0, 0, 0};
struct sensor s;
size_t slen = sizeof(struct sensor);
@@ -358,7 +358,7 @@ void Platform_getBattery(double* level, ACPresence* isOnAC) {
bool found = findDevice("acpibat0", mib, &snsrdev, &sdlen);
- *level = NAN;
+ *percent = NAN;
if (found) {
/* last full capacity */
mib[3] = 7;
@@ -372,9 +372,9 @@ void Platform_getBattery(double* level, ACPresence* isOnAC) {
mib[4] = 3;
if (sysctl(mib, 5, &s, &slen, NULL, 0) != -1) {
double charge = s.value;
- *level = 100 * (charge / last_full_capacity);
+ *percent = 100 * (charge / last_full_capacity);
if (charge >= last_full_capacity) {
- *level = 100;
+ *percent = 100;
}
}
}
diff --git a/openbsd/Platform.h b/openbsd/Platform.h
index dd5c6529..07cde2f8 100644
--- a/openbsd/Platform.h
+++ b/openbsd/Platform.h
@@ -61,6 +61,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted);
-void Platform_getBattery(double* level, ACPresence* isOnAC);
+void Platform_getBattery(double* percent, ACPresence* isOnAC);
#endif
diff --git a/solaris/Platform.c b/solaris/Platform.c
index f3aaa695..014eaf55 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -309,7 +309,7 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
return false;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
- *level = NAN;
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
+ *percent = NAN;
*isOnAC = AC_ERROR;
}
diff --git a/solaris/Platform.h b/solaris/Platform.h
index 0c2e44a2..c3381152 100644
--- a/solaris/Platform.h
+++ b/solaris/Platform.h
@@ -84,6 +84,6 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
unsigned long int* bytesTransmitted,
unsigned long int* packetsTransmitted);
-void Platform_getBattery(double* level, ACPresence* isOnAC);
+void Platform_getBattery(double* percent, ACPresence* isOnAC);
#endif
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
index ee36d9c1..54fde509 100644
--- a/unsupported/Platform.c
+++ b/unsupported/Platform.c
@@ -176,7 +176,7 @@ bool Platform_getNetworkIO(unsigned long int* bytesReceived,
return false;
}
-void Platform_getBattery(double* level, ACPresence* isOnAC) {
- *level = NAN;
+void Platform_getBattery(double* percent, ACPresence* isOnAC) {
+ *percent = NAN;
*isOnAC = AC_ERROR;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy