Use FOR_EACH_STATUS_ITEM everywhere.
authorAndre Noll <maan@systemlinux.org>
Sat, 10 Nov 2007 16:33:06 +0000 (17:33 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 10 Nov 2007 16:33:06 +0000 (17:33 +0100)
audiod.c
audiod_command.c
gui.c
gui_theme.c
para.h
stat.c

index d4b728af4442fdee278c2d6f05e1e46d18c3bc88..b8c072d52cdc80ae48d3c56cbf065cff2d80e457 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -951,7 +951,7 @@ static void close_stat_pipe(void)
                return;
        client_close(stat_task->pcd);
        stat_task->pcd = NULL;
-       for (i = 0; i < NUM_STAT_ITEMS; i++) {
+       FOR_EACH_STATUS_ITEM(i) {
                free(stat_task->stat_item_values[i]);
                stat_task->stat_item_values[i] = NULL;
        }
index a225b76b83f848c5f9ec31b8a141a64d932212ee..855e5cea102e51076b50ad345d014096d9c08e4a 100644 (file)
@@ -259,8 +259,7 @@ int com_stat(int fd, __a_unused int argc, __a_unused char **argv)
                        goto out;
                free(df);
        }
-
-       for (i = 0; i < NUM_STAT_ITEMS; i++) {
+       FOR_EACH_STATUS_ITEM(i) {
                char *tmp, *v;
                if (!((1 << i) & mask))
                        continue;
@@ -529,7 +528,7 @@ void dump_empty_status(void)
 {
        int i;
 
-       FOR_EACH_STAT_ITEM(i) {
+       FOR_EACH_STATUS_ITEM(i) {
                char *tmp = make_message("%s:\n", status_item_list[i]);
                stat_client_write(tmp, i);
                free(tmp);
diff --git a/gui.c b/gui.c
index 40d521bcf81ceb546a9675b5729c182109a07cf6..126b40fe6861b8d61ff6524debcb40ebf7c234b3 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -664,14 +664,15 @@ static void print_all_items(void)
 
        if (!curses_active)
                return;
-       for (i = 0; i < NUM_STAT_ITEMS; i++)
+       FOR_EACH_STATUS_ITEM(i)
                print_stat_item(i);
 }
+
 static void clear_all_items(void)
 {
        int i;
 
-       for (i = 0; i < NUM_STAT_ITEMS; i++) {
+       FOR_EACH_STATUS_ITEM(i) {
                free(stat_content[i]);
                stat_content[i] = para_strdup("");
        }
@@ -683,7 +684,7 @@ static void init_colors(void)
        if (!has_colors())
                msg_n_exit(EXIT_FAILURE, "Error: No color term\n");
        start_color();
-       for (i = 0; i < NUM_STAT_ITEMS; i++)
+       FOR_EACH_STATUS_ITEM(i)
                if (theme.data[i].len)
                        init_pair(i + 1, theme.data[i].fg, theme.data[i].bg);
        init_pair(COLOR_STATUSBAR, theme.sb_fg, theme.sb_bg);
index 262d9d56ac140286e3fe898a2bb6a9fcf2ed7505..b0779791eb9193374fd0948517611af84e1213c3 100644 (file)
@@ -295,8 +295,7 @@ static void init_theme_colorful_blackness(struct gui_theme *t)
 void init_theme(int num, struct gui_theme *t)
 {
        int i;
-
-       for (i = 0; i < NUM_STAT_ITEMS; i++)
+       FOR_EACH_STATUS_ITEM(i)
                t->data[i].len = 0;
        current_theme_num = num;
 
diff --git a/para.h b/para.h
index 2c95f817b5bb8a43538ab93743fa92148c886ba6..9ee318e54e4cb1dae4798f41d60c9187dde517b2 100644 (file)
--- a/para.h
+++ b/para.h
@@ -158,15 +158,15 @@ int tv_convex_combination(const long a, const struct timeval *tv1,
                struct timeval *result);
 void ms2tv(const long unsigned n, struct timeval *tv);
 
+/** The enum of all status items. */
 enum status_items {STATUS_ITEM_ENUM NUM_STAT_ITEMS};
 extern const char *status_item_list[];
-
+/** Loop over each status item. */
+#define FOR_EACH_STATUS_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++)
 int stat_item_valid(const char *item);
 int stat_line_valid(const char *);
 void stat_client_write(const char *msg, int itemnum);
 int stat_client_add(int fd, long unsigned mask);
-/** Loop over each status item. */
-#define FOR_EACH_STAT_ITEM(i) for (i = 0; i < NUM_STAT_ITEMS; i++)
 
 __printf_2_3 void para_log(int, const char*, ...);
 
diff --git a/stat.c b/stat.c
index feb669bc05994ec5a4af92bcb0b8bde7137da103..59ac4235eb28da84ac2cd154a4425ca539f3b16b 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -149,7 +149,7 @@ int stat_item_valid(const char *item)
                PARA_ERROR_LOG("%s\n", "no item");
                return -E_UNKNOWN_STAT_ITEM;
        }
-       FOR_EACH_STAT_ITEM(i)
+       FOR_EACH_STATUS_ITEM(i)
                if (!strcmp(status_item_list[i], item))
                        return i;
        PARA_ERROR_LOG("invalid stat item: %s\n", item);
@@ -173,7 +173,7 @@ int stat_line_valid(const char *line)
        if (!line || !*line)
                return -E_UNKNOWN_STAT_ITEM;
        line_len = strlen(line);
-       FOR_EACH_STAT_ITEM(i) {
+       FOR_EACH_STATUS_ITEM(i) {
                const char *s = status_item_list[i];
                size_t item_len = strlen(s);