summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornia <nia@NetBSD.org>2021-07-27 10:30:13 +0200
committerBenBE <BenBE@geshi.org>2021-08-05 10:47:14 +0200
commit93ca5af953a872eb24faf2cc6a6a7c7671e19d7d (patch)
treea864daeb13f96ff2f620bcfd0fd6236f11fccd25
parentfdcdc54ec45d4512ec8ad9524362e808d1928569 (diff)
netbsd: style: declare variables on first use rather than C89-style
-rw-r--r--netbsd/Platform.c42
1 files changed, 18 insertions, 24 deletions
diff --git a/netbsd/Platform.c b/netbsd/Platform.c
index d26c29cb..b7364926 100644
--- a/netbsd/Platform.c
+++ b/netbsd/Platform.c
@@ -330,49 +330,43 @@ bool Platform_getNetworkIO(NetworkIOData* data) {
}
void Platform_getBattery(double* percent, ACPresence* isOnAC) {
- int fd;
- bool isACAD, isBattery;
- int64_t isPresent, isConnected;
- int64_t curCharge, maxCharge;
- int64_t totalCharge, totalCapacity;
prop_dictionary_t dict, fields, props;
- prop_object_iterator_t devIter, fieldsIter;
- prop_object_t device, class, fieldsArray, curValue, maxValue, descField;
+ prop_object_t device, class;
- totalCharge = 0;
- totalCapacity = 0;
+ int64_t totalCharge = 0;
+ int64_t totalCapacity = 0;
*percent = NAN;
*isOnAC = AC_ERROR;
- fd = open(_PATH_SYSMON, O_RDONLY);
+ int fd = open(_PATH_SYSMON, O_RDONLY);
if (fd == -1)
goto error;
if (prop_dictionary_recv_ioctl(fd, ENVSYS_GETDICTIONARY, &dict) != 0)
goto error;
- devIter = prop_dictionary_iterator(dict);
+ prop_object_iterator_t devIter = prop_dictionary_iterator(dict);
if (devIter == NULL)
goto error;
while ((device = prop_object_iterator_next(devIter)) != NULL) {
- fieldsArray = prop_dictionary_get_keysym(dict, device);
+ prop_object_t fieldsArray = prop_dictionary_get_keysym(dict, device);
if (fieldsArray == NULL)
goto error;
- fieldsIter = prop_array_iterator(fieldsArray);
+ prop_object_iterator_t fieldsIter = prop_array_iterator(fieldsArray);
if (fieldsIter == NULL)
goto error;
- isACAD = false;
- isBattery = false;
+ bool isACAdapter = false;
+ bool isBattery = false;
/* only assume battery is not present if explicitly stated */
- isPresent = 1;
- isConnected = 0;
- curCharge = 0;
- maxCharge = 0;
+ int64_t isPresent = 1;
+ int64_t isConnected = 0;
+ int64_t curCharge = 0;
+ int64_t maxCharge = 0;
while ((fields = prop_object_iterator_next(fieldsIter)) != NULL) {
props = prop_dictionary_get(fields, "device-properties");
@@ -385,16 +379,16 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
*/
if (prop_string_equals_cstring(class, "ac-adapter")) {
- isACAD = true;
+ isACAdapter = true;
} else if (prop_string_equals_cstring(class, "battery")) {
isBattery = true;
}
continue;
}
- curValue = prop_dictionary_get(fields, "cur-value");
- maxValue = prop_dictionary_get(fields, "max-value");
- descField = prop_dictionary_get(fields, "description");
+ prop_object_t curValue = prop_dictionary_get(fields, "cur-value");
+ prop_object_t maxValue = prop_dictionary_get(fields, "max-value");
+ prop_object_t descField = prop_dictionary_get(fields, "description");
if (descField == NULL || curValue == NULL)
continue;
@@ -416,7 +410,7 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
totalCapacity += maxCharge;
}
- if (isACAD) {
+ if (isACAdapter) {
*isOnAC = isConnected ? AC_PRESENT : AC_ABSENT;
}
}

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