Abstract out active pools count.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/main.c b/main.c
index fffffd2..b052ef9 100644
--- a/main.c
+++ b/main.c
@@ -1398,11 +1398,22 @@ static int curses_int(const char *query)
static bool input_pool(bool live);
+static int active_pools(void)
+{
+ int ret = 0;
+ int i;
+
+ for (i = 0; i < total_pools; i++) {
+ if ((pools[i])->enabled)
+ ret++;
+ }
+ return ret;
+}
+
static void display_pools(void)
{
- int i, active = 0;
struct pool *pool;
- int selected;
+ int selected, i;
char input;
opt_loginput = true;
@@ -1422,7 +1433,8 @@ updated:
}
retry:
wprintw(logwin, "\nCurrent pool management strategy: %s\n", strategies[pool_strategy]);
- wprintw(logwin, "[A]dd pool [D]isable pool [E]nable pool [S]witch pool\n");
+ wprintw(logwin, "[A]dd pool [R]emove pool [D]isable pool [E]nable pool\n");
+ wprintw(logwin, "[C]hange management strategy [S]witch pool\n");
wprintw(logwin, "Or press any other key to continue\n");
wrefresh(logwin);
pthread_mutex_unlock(&curses_lock);
@@ -1442,11 +1454,7 @@ retry:
switch_pools(pool);
goto updated;
} else if (!strncasecmp(&input, "d", 1)) {
- for (i = 0; i < total_pools; i++) {
- if ((pools[i])->enabled)
- active++;
- }
- if (active <= 1) {
+ if (active_pools() <= 1) {
wprintw(logwin, "Cannot disable last pool");
goto retry;
}