Skip to content

Commit fb3cac7

Browse files
author
Sebastian Kuttnig
committed
drivers/failover.{c,h}: make UPS priorities more readable in code
Signed-off-by: Sebastian Kuttnig <sebastian.kuttnig@gmail.com>
1 parent 0937f25 commit fb3cac7

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/failover.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,21 +1381,21 @@ static ups_device_t *get_primary_candidate(void)
13811381
__func__, ups->socketname, elapsed_force, ups->force_primary);
13821382
}
13831383
else if (ups_passes_status_filters(ups)) {
1384-
priority = PRIORITY_USERFILTERS;
1384+
priority = PRIORITY_STATUSFILTERS;
13851385
}
13861386
else if (arg_strict_filtering) {
13871387
upsdebugx(4, "%s: [%s]: 'strict_filtering' is enabled, considering "
13881388
"only status filters, but not the default set of lower priorities",
13891389
__func__, ups->socketname);
13901390
}
13911391
else if (ups_has_flag(ups, (ups_flags_t)(UPS_FLAG_DATA_OK | UPS_FLAG_ONLINE))) {
1392-
priority = PRIORITY_GOOD;
1392+
priority = PRIORITY_ONLINE;
13931393
}
13941394
else if (ups_has_flag(ups, UPS_FLAG_DATA_OK)) {
1395-
priority = PRIORITY_WEAK;
1395+
priority = PRIORITY_BATTERY;
13961396
}
13971397
else {
1398-
priority = PRIORITY_LASTRESORT;
1398+
priority = PRIORITY_STALE;
13991399
}
14001400
}
14011401

@@ -1411,7 +1411,7 @@ static ups_device_t *get_primary_candidate(void)
14111411
best_runtime = rt;
14121412
best_runtime_low = rt_low;
14131413
}
1414-
else if (priority == best_priority && arg_check_runtime && priority >= PRIORITY_WEAK) {
1414+
else if (priority == best_priority && arg_check_runtime && priority >= PRIORITY_BATTERY) {
14151415
/* All devices are not fully online and runtime checking is enabled, compare values: */
14161416
if (has_better_runtime(rt, rt_low, best_runtime, best_runtime_low, arg_check_runtime)) {
14171417
best_choice = ups;

drivers/failover.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
typedef enum {
4848
PRIORITY_SKIPPED = -1,
4949
PRIORITY_FORCED = 0,
50-
PRIORITY_USERFILTERS = 1,
51-
PRIORITY_GOOD = 2,
52-
PRIORITY_WEAK = 3,
53-
PRIORITY_LASTRESORT = 4
50+
PRIORITY_STATUSFILTERS = 1,
51+
PRIORITY_ONLINE = 2,
52+
PRIORITY_BATTERY = 3,
53+
PRIORITY_STALE = 4
5454
} ups_priority_t;
5555

5656
typedef enum {

0 commit comments

Comments
 (0)