the big relocation patch
authorPhil <n0-1@users.sourceforge.net>
Sat, 29 Mar 2008 06:24:04 +0000 (06:24 +0000)
committerPhil <n0-1@users.sourceforge.net>
Sat, 29 Mar 2008 06:24:04 +0000 (06:24 +0000)
* this moves all declarations to the beginning of their block
  to prevent mixed declarations and code

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1068 7f574dfc-610e-0410-a909-a81674777703

src/conky.c
src/fs.c
src/linux.c
src/mboxscan.c
src/mpd.c
src/prss.c
src/rss.c
src/top.c

index eed0ae3..8edbc24 100644 (file)
@@ -707,10 +707,11 @@ static void new_font(char *buf, char *args)
 
 inline void graph_append(struct special_t *graph, double f)
 {
+       int i;
+
        if (!graph->scaled && f > graph->graph_scale) {
                f = graph->graph_scale;
        }
-       int i;
 
        if (graph->scaled) {
                graph->graph_scale = 1;
@@ -973,10 +974,12 @@ static int spaced_print(char *buf, int size, const char *format, int width,
                const char *func_name, ...) {
        int len;
        va_list argp;
+       char *tempbuf;
+
        if (size < 1) {
                return 0;
        }
-       char *tempbuf = malloc(size * sizeof(char));
+       tempbuf = malloc(size * sizeof(char));
 
        // Passes the varargs along to vsnprintf
        va_start(argp, func_name);
@@ -1464,9 +1467,10 @@ static void generate_text_internal(char *p, int p_max_size,
 struct mail_s *parse_mail_args(char type, const char *arg)
 {
        struct mail_s *mail;
+       char *tmp;
+
        mail = malloc(sizeof(struct mail_s));
        memset(mail, 0, sizeof(struct mail_s));
-       char *tmp;
 
        if (sscanf(arg, "%128s %128s %128s", mail->host, mail->user, mail->pass)
                        != 3) {
@@ -1520,8 +1524,8 @@ struct mail_s *parse_mail_args(char type, const char *arg)
        }
        tmp = strstr(arg, "-e ");
        if (tmp) {
-               tmp += 3;
                int len = 1024;
+               tmp += 3;
 
                if (tmp[0] == '\'') {
                        len = strstr(tmp + 1, "'") - tmp - 1;
@@ -1556,6 +1560,10 @@ void *imap_thread(void *arg)
                exit(1);
        }
        while (fail < 5) {
+               struct timeval timeout;
+               int res;
+               fd_set fdset;
+
                if (fail > 0) {
                        ERR("Trying IMAP connection again for %s@%s (try %i/5)",
                                mail->user, mail->host, fail + 1);
@@ -1580,9 +1588,6 @@ void *imap_thread(void *arg)
                        fail++;
                        goto next_iteration;
                }
-               struct timeval timeout;
-               int res;
-               fd_set fdset;
 
                timeout.tv_sec = 60;    // 60 second timeout i guess
                timeout.tv_usec = 0;
@@ -1741,6 +1746,10 @@ void *pop3_thread(void *arg)
                exit(1);
        }
        while (fail < 5) {
+               struct timeval timeout;
+               int res;
+               fd_set fdset;
+
                if (fail > 0) {
                        ERR("Trying POP3 connection again for %s@%s (try %i/5)",
                                mail->user, mail->host, fail + 1);
@@ -1765,9 +1774,6 @@ void *pop3_thread(void *arg)
                        fail++;
                        goto next_iteration;
                }
-               struct timeval timeout;
-               int res;
-               fd_set fdset;
 
                timeout.tv_sec = 60;    // 60 second timeout i guess
                timeout.tv_usec = 0;
@@ -1926,13 +1932,16 @@ next_iteration:
 
 void *threaded_exec(void *arg)
 {
+       FILE *fp;
+       char *p2;
+       int n2;
+       struct text_object *obj = (struct text_object *)arg;
        while (1) {
-               struct text_object *obj = (struct text_object *)arg;
-               char *p2 = obj->data.texeci.buffer;
-               FILE *fp = popen(obj->data.texeci.cmd, "r");
+               p2 = obj->data.texeci.buffer;
+               fp = popen(obj->data.texeci.cmd, "r");
 
                timed_thread_lock(obj->data.texeci.p_timed_thread);
-               int n2 = fread(p2, 1, text_buffer_size, fp);
+               n2 = fread(p2, 1, text_buffer_size, fp);
 
                pclose(fp);
                p2[n2] = '\0';
@@ -3826,6 +3835,7 @@ static struct text_object_list *extract_variable_text_internal(const char *const
        struct text_object_list *retval;
        struct text_object *obj;
        char *p, *s, *orig_p;
+       long line;
 
        p = strdup(const_p);
        s = orig_p = p;
@@ -3834,7 +3844,7 @@ static struct text_object_list *extract_variable_text_internal(const char *const
        memset(retval, 0, sizeof(struct text_object_list));
        retval->text_object_count = 0;
 
-       long line = text_lines;
+       line = text_lines;
 
        while (*p) {
                if (*p == '\n') {
@@ -4646,17 +4656,20 @@ static void generate_text_internal(char *p, int p_max_size,
                                }
                        }
                        OBJ(execp) {
-                               FILE *fp = popen(obj->data.s, "r");
-                               fread(p, 1, p_max_size, fp);
+                               FILE *fp;
+                               struct information *my_info;
+                               struct text_object_list *text_objects;
+                               int length;
 
+                               fp = popen(obj->data.s, "r");
+                               fread(p, 1, p_max_size, fp);
                                pclose(fp);
 
-                               struct information *my_info =
-                                       malloc(sizeof(struct information));
+                               my_info = malloc(sizeof(struct information));
                                memcpy(my_info, cur, sizeof(struct information));
-                               struct text_object_list *text_objects = parse_conky_vars(p, p, my_info);
+                               text_objects = parse_conky_vars(p, p, my_info);
 
-                               int length = strlen(p);
+                               length = strlen(p);
 
                                p[length] = '\0';
                                if (length > 0 && p[length - 1] == '\n') {
@@ -4671,6 +4684,7 @@ static void generate_text_internal(char *p, int p_max_size,
                                char *p2 = p;
                                FILE *fp = popen(obj->data.s, "r");
                                int n2 = fread(p, 1, p_max_size, fp);
+                               double barnum;
 
                                pclose(fp);
                                p[n2] = '\0';
@@ -4684,7 +4698,6 @@ static void generate_text_internal(char *p, int p_max_size,
                                        }
                                        p2++;
                                }
-                               double barnum;
 
                                if (sscanf(p, "%lf", &barnum) == 0) {
                                        ERR("reading execbar value failed (perhaps it's not the "
@@ -4702,6 +4715,7 @@ static void generate_text_internal(char *p, int p_max_size,
                                char *p2 = p;
                                FILE *fp = popen(obj->data.s, "r");
                                int n2 = fread(p, 1, p_max_size, fp);
+                               double barnum;
 
                                pclose(fp);
                                p[n2] = '\0';
@@ -4714,7 +4728,6 @@ static void generate_text_internal(char *p, int p_max_size,
                                        }
                                        p2++;
                                }
-                               double barnum;
 
                                if (sscanf(p, "%lf", &barnum) == 0) {
                                        ERR("reading execgraph value failed (perhaps it's not the "
@@ -4736,6 +4749,7 @@ static void generate_text_internal(char *p, int p_max_size,
                                        char *p2 = p;
                                        FILE *fp = popen(obj->data.execi.cmd, "r");
                                        int n2 = fread(p, 1, p_max_size, fp);
+                                       float barnum;
 
                                        pclose(fp);
                                        p[n2] = '\0';
@@ -4749,7 +4763,6 @@ static void generate_text_internal(char *p, int p_max_size,
                                                }
                                                p2++;
                                        }
-                                       float barnum;
 
                                        if (sscanf(p, "%f", &barnum) == 0) {
                                                ERR("reading execibar value failed (perhaps it's not "
@@ -4773,6 +4786,7 @@ static void generate_text_internal(char *p, int p_max_size,
                                        char *p2 = p;
                                        FILE *fp = popen(obj->data.execi.cmd, "r");
                                        int n2 = fread(p, 1, p_max_size, fp);
+                                       float barnum;
 
                                        pclose(fp);
                                        p[n2] = '\0';
@@ -4786,7 +4800,6 @@ static void generate_text_internal(char *p, int p_max_size,
                                                }
                                                p2++;
                                        }
-                                       float barnum;
 
                                        if (sscanf(p, "%f", &barnum) == 0) {
                                                ERR("reading execigraph value failed (perhaps it's not "
@@ -4825,10 +4838,10 @@ static void generate_text_internal(char *p, int p_max_size,
                                // parse_conky_vars(output, p, cur);
                        }
                        OBJ(execpi) {
+                               struct text_object_list *text_objects = 0;
                                struct information *my_info =
                                        malloc(sizeof(struct information));
                                memcpy(my_info, cur, sizeof(struct information));
-                               struct text_object_list *text_objects = 0;
 
                                if (current_update_time - obj->data.execi.last_update
                                                < obj->data.execi.interval
@@ -5192,9 +5205,9 @@ static void generate_text_internal(char *p, int p_max_size,
                                        } else if (!strcmp(obj->data.rss.action, "item_titles")) {
                                                if (data->item_count > 0) {
                                                        int itmp;
+                                                       int show;
 
                                                        p[0] = 0;
-                                                       int show;
 
                                                        if (obj->data.rss.act_par > data->item_count) {
                                                                show = data->item_count;
@@ -5290,11 +5303,12 @@ static void generate_text_internal(char *p, int p_max_size,
                                new_alignc(p, obj->data.i);
                        }
                        OBJ(if_empty) {
+                               struct text_object_list *text_objects;
                                struct information *my_info =
                                        malloc(sizeof(struct information));
-
                                memcpy(my_info, cur, sizeof(struct information));
-                               struct text_object_list *text_objects = parse_conky_vars(obj->data.ifblock.s, p, my_info);
+                               text_objects = parse_conky_vars(obj->data.ifblock.s, p, my_info);
+
                                if (strlen(p) != 0) {
                                        i = obj->data.ifblock.pos;
                                        if_jumped = 1;
@@ -5472,14 +5486,16 @@ static void generate_text_internal(char *p, int p_max_size,
                        }
                        OBJ(tztime) {
                                char *oldTZ = NULL;
+                               time_t t;
+                               struct tm *tm;
 
                                if (obj->data.tztime.tz) {
                                        oldTZ = getenv("TZ");
                                        setenv("TZ", obj->data.tztime.tz, 1);
                                        tzset();
                                }
-                               time_t t = time(NULL);
-                               struct tm *tm = localtime(&t);
+                               t = time(NULL);
+                               tm = localtime(&t);
 
                                setlocale(LC_TIME, "");
                                strftime(p, p_max_size, obj->data.tztime.fmt, tm);
@@ -5898,11 +5914,12 @@ static void generate_text_internal(char *p, int p_max_size,
                                                < obj->data.tail.interval) {
                                        snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
                                } else {
-                                       obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
                                        long nl = 0, bsize;
                                        int iter;
 
+                                       obj->data.tail.last_update = current_update_time;
+
                                        if (obj->data.tail.fd != -1) {
                                                tail_pipe(obj, p, p_max_size);
                                                goto head;
@@ -5974,11 +5991,12 @@ head:
                                                < obj->data.tail.interval) {
                                        snprintf(p, p_max_size, "%s", obj->data.tail.buffer);
                                } else {
-                                       obj->data.tail.last_update = current_update_time;
                                        FILE *fp;
                                        long nl = 0;
                                        int iter;
 
+                                       obj->data.tail.last_update = current_update_time;
+
                                        fp = fopen(obj->data.tail.logfile, "rt");
                                        if (fp == NULL) {
                                                /* Send one message, but do not consistently spam
@@ -6223,17 +6241,18 @@ static inline int get_string_width(const char *s)
 
 static inline int get_string_width_special(char *s)
 {
+#ifdef X11
+       char *p, *final;
+       int index = 1;
+       int width = 0;
+       unsigned int i;
+
        if (!s) {
                return 0;
        }
-#ifdef X11
-       char *p, *final;
 
        p = strdup(s);
        final = p;
-       int index = 1;
-       int width = 0;
-       unsigned int i;
 
        while (*p) {
                if (*p == SPECIAL_CHAR) {
@@ -6257,7 +6276,7 @@ static inline int get_string_width_special(char *s)
        free(final);
        return width;
 #else
-       return strlen(s);
+       return (s) ? strlen(s) : 0;
 #endif /* X11 */
 }
 
@@ -6445,12 +6464,14 @@ static inline void set_foreground_color(long c)
 
 static void draw_string(const char *s)
 {
-       if (s[0] == '\0') {
-               return;
-       }
        int i, i2, pos, width_of_s;
        int max = 0;
        int added;
+       char space[2];
+
+       if (s[0] == '\0') {
+               return;
+       }
 
        width_of_s = get_string_width(s);
        if (out_to_console) {
@@ -6462,7 +6483,6 @@ static void draw_string(const char *s)
        strncpy(tmpstring1, s, text_buffer_size - 1);
        pos = 0;
        added = 0;
-       char space[2];
 
        snprintf(space, 2, " ");
 #ifdef X11
@@ -6535,6 +6555,7 @@ long redmask, greenmask, bluemask;
 
 void set_up_gradient(void)
 {
+       int i;
 #ifdef X11
        colour_depth = DisplayPlanes(display, screen);
 #else
@@ -6544,7 +6565,6 @@ void set_up_gradient(void)
                ERR("using non-standard colour depth, gradients may look like a "
                        "lolly-pop");
        }
-       int i;
 
        redmask = 0;
        greenmask = 0;
@@ -6625,14 +6645,17 @@ inline unsigned long do_gradient(unsigned long first_colour,
 inline unsigned long gradient_max(unsigned long first_colour,
                unsigned long last_colour)
 {
+       int red1, green1, blue1;                                // first colour
+       int red2, green2, blue2;                                // second colour
+       int red3 = 0, green3 = 0, blue3 = 0;                    // difference
+       long redshift, greenshift;
+       int max;
+
        if (colour_depth == 0) {
                set_up_gradient();
        }
-       int red1, green1, blue1;                                // first colour
-       int red2, green2, blue2;                                // second colour
-       long redshift = (2 * colour_depth / 3 + colour_depth % 3);
-       long greenshift = (colour_depth / 3);
-       int red3 = 0, green3 = 0, blue3 = 0;    // difference
+       redshift = (2 * colour_depth / 3 + colour_depth % 3);
+       greenshift = (colour_depth / 3);
 
        red1 = (first_colour & redmask) >> redshift;
        green1 = (first_colour & greenmask) >> greenshift;
@@ -6643,7 +6666,7 @@ inline unsigned long gradient_max(unsigned long first_colour,
        red3 = abs(red1 - red2);
        green3 = abs(green1 - green2);
        blue3 = abs(blue1 - blue2);
-       int max = red3;
+       max = red3;
 
        if (green3 > max) {
                max = green3;
@@ -6658,11 +6681,12 @@ static void draw_line(char *s)
 {
 #ifdef X11
        char *p;
+       int cur_y_add = 0;
+       short font_h;
 
        cur_x = text_start_x;
        cur_y += font_ascent();
-       int cur_y_add = 0;
-       short font_h = font_height();
+       font_h = font_height();
 
        /* find specials and draw stuff */
        p = s;
@@ -6710,13 +6734,14 @@ static void draw_line(char *s)
 
                                case BAR:
                                {
+                                       int h, bar_usage, by;
                                        if (cur_x - text_start_x > maximum_width
                                                        && maximum_width > 0) {
                                                break;
                                        }
-                                       int h = specials[special_index].height;
-                                       int bar_usage = specials[special_index].arg;
-                                       int by = cur_y - (font_ascent() / 2) - 1;
+                                       h = specials[special_index].height;
+                                       bar_usage = specials[special_index].arg;
+                                       by = cur_y - (font_ascent() / 2) - 1;
 
                                        if (h < font_height()) {
                                                by -= h / 2 - 1;
@@ -6745,13 +6770,18 @@ static void draw_line(char *s)
 
                                case GRAPH:
                                {
+                                       int h, by, i, j = 0;
+                                       int gradient_size = 0;
+                                       float gradient_factor = 0;
+                                       float gradient_update = 0;
+                                       unsigned long last_colour = current_color;
+                                       unsigned long tmpcolour = current_color;
                                        if (cur_x - text_start_x > maximum_width
                                                        && maximum_width > 0) {
                                                break;
                                        }
-                                       int h = specials[special_index].height;
-                                       unsigned long last_colour = current_color;
-                                       int by = cur_y - (font_ascent() / 2) - 1;
+                                       h = specials[special_index].height;
+                                       by = cur_y - (font_ascent() / 2) - 1;
 
                                        if (h < font_height()) {
                                                by -= h / 2 - 1;
@@ -6771,12 +6801,6 @@ static void draw_line(char *s)
                                        }
                                        XSetLineAttributes(display, window.gc, 1, LineSolid,
                                                CapButt, JoinMiter);
-                                       int i;
-                                       int j = 0;
-                                       int gradient_size = 0;
-                                       float gradient_factor = 0;
-                                       float gradient_update = 0;
-                                       unsigned long tmpcolour = current_color;
 
                                        if (specials[special_index].last_colour != 0
                                                        || specials[special_index].first_colour != 0) {
@@ -6988,8 +7012,8 @@ static void draw_stuff(void)
        }
 
        if (draw_outline) {
-               selected_font = 0;
                int i, j;
+               selected_font = 0;
 
                for (i = -1; i < 2; i++) {
                        for (j = -1; j < 2; j++) {
@@ -7059,31 +7083,31 @@ static void main_loop(void)
 {
 #ifdef SIGNAL_BLOCKING
        sigset_t newmask, oldmask;
-
-       sigemptyset(&newmask);
-       sigaddset(&newmask, SIGINT);
-       sigaddset(&newmask, SIGTERM);
-       sigaddset(&newmask, SIGUSR1);
 #endif
-
 #ifdef X11
        Region region = XCreateRegion();
 
 #ifdef HAVE_XDAMAGE
+       Damage damage;
+       XserverRegion region2, part;
        int event_base, error_base;
 
        if (!XDamageQueryExtension(display, &event_base, &error_base)) {
                ERR("Xdamage extension unavailable");
        }
-       Damage damage = XDamageCreate(display, window.window,
-               XDamageReportNonEmpty);
-       XserverRegion region2 = XFixesCreateRegionFromWindow(display,
-               window.window, 0);
-       XserverRegion part = XFixesCreateRegionFromWindow(display,
-               window.window, 0);
+       damage = XDamageCreate(display, window.window, XDamageReportNonEmpty);
+       region2 = XFixesCreateRegionFromWindow(display, window.window, 0);
+       part = XFixesCreateRegionFromWindow(display, window.window, 0);
 #endif /* HAVE_XDAMAGE */
 #endif /* X11 */
 
+#ifdef SIGNAL_BLOCKING
+       sigemptyset(&newmask);
+       sigaddset(&newmask, SIGINT);
+       sigaddset(&newmask, SIGTERM);
+       sigaddset(&newmask, SIGUSR1);
+#endif
+
        info.looped = 0;
        while (total_run_times == 0 || info.looped < total_run_times) {
                info.looped++;
@@ -8417,6 +8441,10 @@ static const struct option longopts[] = {
 
 int main(int argc, char **argv)
 {
+#ifdef X11
+       char *s, *temp;
+       unsigned int x;
+#endif
        struct sigaction act, oact;
 
        g_signal_pending = 0;
@@ -8429,9 +8457,6 @@ int main(int argc, char **argv)
 
        /* handle command line parameters that don't change configs */
 #ifdef X11
-       char *s, *temp;
-       unsigned int x;
-
        if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && *s)
                        || ((s = getenv("LANG")) && *s)) {
                temp = (char *) malloc((strlen(s) + 1) * sizeof(char));
index e858a5c..7ea5c59 100644 (file)
--- a/src/fs.c
+++ b/src/fs.c
@@ -140,6 +140,7 @@ void get_fs_type(const char *path, char *result)
 
        /* TODO: walk up the directory tree so it works on on paths that are not actually mount points. */
 
+       struct mntent *me;
        FILE *mtab = setmntent("/etc/mtab", "r");
 
        if (mtab == NULL) {
@@ -148,7 +149,7 @@ void get_fs_type(const char *path, char *result)
                return;
        }
 
-       struct mntent *me = getmntent(mtab);
+       me = getmntent(mtab);
 
        // find our path in the mtab
        while (strcmp(path, me->mnt_dir) && getmntent(mtab));
index e290818..6ee4bd8 100644 (file)
@@ -569,11 +569,11 @@ void get_cpu_count(void)
 {
        FILE *stat_fp;
        static int rep = 0;
+       char buf[256];
 
        if (info.cpu_usage) {
                return;
        }
-       char buf[256];
 
        if (!(stat_fp = open_file("/proc/stat", &rep))) {
                return;
@@ -648,6 +648,7 @@ inline static void update_stat(void)
                        sscanf(buf, "%*s %hu", &info.run_procs);
                        info.mask |= (1 << INFO_RUN_PROCS);
                } else if (strncmp(buf, "cpu", 3) == 0) {
+                       double delta;
                        index = isdigit(buf[3]) ? ((int) buf[3]) - 0x2F : 0;
                        sscanf(buf, stat_template, &(cpu[index].cpu_user),
                                &(cpu[index].cpu_nice), &(cpu[index].cpu_system),
@@ -664,7 +665,7 @@ inline static void update_stat(void)
                                (cpu[index].cpu_idle + cpu[index].cpu_iowait);
                        info.mask |= (1 << INFO_CPU);
 
-                       double delta = current_update_time - last_update_time;
+                       delta = current_update_time - last_update_time;
 
                        if (delta <= 0.001) {
                                break;
@@ -1523,9 +1524,9 @@ void get_battery_stuff(char *buf, unsigned int n, const char *bat, int item)
 {
        static int idx, rep = 0, rep2 = 0;
        char acpi_path[128];
+       char sysfs_path[128];
 
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
-       char sysfs_path[128];
        snprintf(sysfs_path, 127, SYSFS_BATTERY_BASE_PATH "/%s/uevent", bat);
 
        init_batteries();
@@ -1825,9 +1826,10 @@ int get_battery_perct(const char *bat)
        static int rep = 0;
        int idx;
        char acpi_path[128];
+       char sysfs_path[128];
+       int remaining_capacity = -1;
 
        snprintf(acpi_path, 127, ACPI_BATTERY_BASE_PATH "/%s/state", bat);
-       char sysfs_path[128];
        snprintf(sysfs_path, 127, SYSFS_BATTERY_BASE_PATH "/%s/uevent", bat);
 
        init_batteries();
@@ -1851,8 +1853,6 @@ int get_battery_perct(const char *bat)
                acpi_bat_fp[idx] = open_file(acpi_path, &rep);
        }
 
-       int remaining_capacity = -1;
-
        if (sysfs_bat_fp[idx] != NULL) {
                /* SYSFS */
                while (!feof(sysfs_bat_fp[idx])) {
@@ -2087,6 +2087,7 @@ void update_diskio(void)
        unsigned int current_write = 0;
        unsigned int reads, writes = 0;
        int col_count = 0;
+       int tot, tot_read, tot_write;
 
        if (!(fp = open_file("/proc/diskstats", &rep))) {
                diskio_value = 0;
@@ -2145,9 +2146,9 @@ void update_diskio(void)
        /* since the values in /proc/diststats are absolute, we have to substract
         * our last reading. The numbers stand for "sectors read", and we therefore
         * have to divide by two to get KB */
-       int tot = ((double) (current - last) / 2);
-       int tot_read = ((double) (current_read - last_read) / 2);
-       int tot_write = ((double) (current_write - last_write) / 2);
+       tot = ((double) (current - last) / 2);
+       tot_read = ((double) (current_read - last_read) / 2);
+       tot_write = ((double) (current_write - last_write) / 2);
 
        if (last_read > current_read) {
                tot_read = 0;
@@ -2206,14 +2207,14 @@ commands:       enable, disable
 
 void get_ibm_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
 {
-       if (!p_client_buffer || client_buffer_size <= 0) {
-               return;
-       }
-
        FILE *fp;
        unsigned int speed = 0;
        char fan[128];
 
+       if (!p_client_buffer || client_buffer_size <= 0) {
+               return;
+       }
+
        snprintf(fan, 127, "%s/fan", IBM_ACPI_DIR);
 
        fp = fopen(fan, "r");
@@ -2262,6 +2263,9 @@ static double last_ibm_acpi_temp_time;
 void get_ibm_acpi_temps(void)
 {
 
+       FILE *fp;
+       char thermal[128];
+
        /* don't update too often */
        if (current_update_time - last_ibm_acpi_temp_time < 10.00) {
                return;
@@ -2272,10 +2276,6 @@ void get_ibm_acpi_temps(void)
                return;
        } */
 
-       FILE *fp;
-
-       char thermal[128];
-
        snprintf(thermal, 127, "%s/thermal", IBM_ACPI_DIR);
        fp = fopen(thermal, "r");
 
@@ -2313,17 +2313,16 @@ commands:       level <level> (<level> is 0-15)
 
 void get_ibm_acpi_volume(char *p_client_buffer, size_t client_buffer_size)
 {
+       FILE *fp;
+       char volume[128];
+       unsigned int vol = -1;
+       char mute[3] = "";
+
        if (!p_client_buffer || client_buffer_size <= 0) {
                return;
        }
 
-       FILE *fp;
-
-       char volume[128];
-
        snprintf(volume, 127, "%s/volume", IBM_ACPI_DIR);
-       unsigned int vol = -1;
-       char mute[3] = "";
 
        fp = fopen(volume, "r");
        if (fp != NULL) {
@@ -2369,14 +2368,14 @@ commands:       level <level> (<level> is 0-7)
 
 void get_ibm_acpi_brightness(char *p_client_buffer, size_t client_buffer_size)
 {
-       if (!p_client_buffer || client_buffer_size <= 0) {
-               return;
-       }
-
        FILE *fp;
        unsigned int brightness = 0;
        char filename[128];
 
+       if (!p_client_buffer || client_buffer_size <= 0) {
+               return;
+       }
+
        snprintf(filename, 127, "%s/brightness", IBM_ACPI_DIR);
 
        fp = fopen(filename, "r");
index 49c921b..135cff8 100644 (file)
@@ -64,6 +64,8 @@ void mbox_scan(char *args, char *output, size_t max_len)
        int force_rescan = 0;
        char buf[text_buffer_size];
        struct stat statbuf;
+       struct ring_list *curr = 0, *prev = 0, *startlist = 0;
+       FILE *fp;
 
        /* output was set to 1 after malloc'ing in conky.c */
        /* -> beeing able to test it here for catching SIGUSR1 */
@@ -115,8 +117,9 @@ void mbox_scan(char *args, char *output, size_t max_len)
                }
                /* encapsulated with "'s find first occurrence of " */
                if (args[strlen(args) - 1] == '"') {
+                       char *start;
                        strncpy(mbox_mail_spool, args, DEFAULT_TEXT_BUFFER_SIZE);
-                       char *start = strchr(mbox_mail_spool, '"') + 1;
+                       start = strchr(mbox_mail_spool, '"') + 1;
 
                        start[(long) (strrchr(mbox_mail_spool, '"') - start)] = '\0';
                        strncpy(mbox_mail_spool, start, DEFAULT_TEXT_BUFFER_SIZE);
@@ -176,8 +179,6 @@ void mbox_scan(char *args, char *output, size_t max_len)
 
        /* build up double-linked ring-list to hold data, while scanning down the
         * mbox */
-       struct ring_list *curr = 0, *prev = 0, *startlist = 0;
-
        for (i = 0; i < print_mails; i++) {
                curr = (struct ring_list *) malloc(sizeof(struct ring_list));
                curr->from = (char *) malloc(sizeof(char[from_width + 1]));
@@ -200,8 +201,6 @@ void mbox_scan(char *args, char *output, size_t max_len)
        curr->next = startlist;
 
        /* mbox */
-       FILE *fp;
-
        fp = fopen(mbox_mail_spool, "r");
        if (!fp) {
                return;
@@ -338,10 +337,10 @@ void mbox_scan(char *args, char *output, size_t max_len)
        fclose(fp);
 
        output[0] = '\0';
-       struct ring_list *tmp;
 
        i = print_mails;
        while (i) {
+               struct ring_list *tmp;
                if (curr->from[0] != '\0') {
                        if (i != print_mails) {
                                snprintf(buf, text_buffer_size, "\nF: %-*s S: %-*s", from_width,
index 625b419..e517dce 100644 (file)
--- a/src/mpd.c
+++ b/src/mpd.c
@@ -136,6 +136,9 @@ void *update_mpd(void *arg)
        }
 
        while (1) {
+               mpd_Status *status;
+               mpd_InfoEntity *entity;
+
                if (!current_info->conn) {
                        current_info->conn = mpd_newConnection(current_info->mpd.host,
                                current_info->mpd.port, 10);
@@ -163,9 +166,6 @@ void *update_mpd(void *arg)
                        continue;
                }
 
-               mpd_Status *status;
-               mpd_InfoEntity *entity;
-
                mpd_sendStatusCommand(current_info->conn);
                if ((status = mpd_getStatus(current_info->conn)) == NULL) {
                        // ERR("MPD error: %s\n", current_info->conn->errorStr);
index 5c7d191..5a57f6b 100644 (file)
@@ -78,12 +78,13 @@ static inline void read_item(PRSS_Item *res, xmlNodePtr data)
 
        res->title = res->link = res->description = NULL;
        for (; data; data = data->next) {
+               xmlNodePtr child;
                const char *name;
 
                if (data->type != XML_ELEMENT_NODE) {
                        continue;
                }
-               xmlNodePtr child = data->children;
+               child = data->children;
 
                if (!child) {
                        continue;
@@ -107,12 +108,13 @@ static inline void read_item(PRSS_Item *res, xmlNodePtr data)
 }
 static inline void read_element(PRSS *res, xmlNodePtr n)
 {
+       xmlNodePtr child;
        const char *name;
 
        if (n->type != XML_ELEMENT_NODE) {
                return;
        }
-       xmlNodePtr child = n->children;
+       child = n->children;
 
        if (!child) {
                return;
@@ -151,6 +153,8 @@ static inline void read_element(PRSS *res, xmlNodePtr n)
 static inline int parse_rss_2_0(PRSS *res, xmlNodePtr root)
 {
        xmlNodePtr channel = root->children;
+       xmlNodePtr n;
+       int items = 0;
 
        while (channel && (channel->type != XML_ELEMENT_NODE
                        || strcmp((const char *) channel->name, "channel"))) {
@@ -160,9 +164,6 @@ static inline int parse_rss_2_0(PRSS *res, xmlNodePtr root)
                return 0;
        }
 
-       int items = 0;
-       xmlNodePtr n;
-
        for (n = channel->children; n; n = n->next) {
                if (n->type == XML_ELEMENT_NODE &&
                                !strcmp((const char *) n->name, "item")) {
index 222c41f..f1b69fb 100644 (file)
--- a/src/rss.c
+++ b/src/rss.c
@@ -115,12 +115,6 @@ PRSS *get_rss_info(char *uri, int delay)
        CURL *curl = NULL;
        CURLcode res;
 
-       // curl temps
-       struct MemoryStruct chunk;
-
-       chunk.memory = NULL;
-       chunk.size = 0;
-
        // pointers to struct
        feed *curfeed = NULL;
        PRSS *curdata = NULL;
@@ -128,6 +122,12 @@ PRSS *get_rss_info(char *uri, int delay)
 
        int i;
 
+       // curl temps
+       struct MemoryStruct chunk;
+
+       chunk.memory = NULL;
+       chunk.size = 0;
+
        // first seek for the uri in list
        for (i = 0; i < num_feeds; i++) {
                if (feeds[i].uri != NULL) {
index 4423cf9..5582ed1 100644 (file)
--- a/src/top.c
+++ b/src/top.c
@@ -106,9 +106,7 @@ static struct process *new_process(int p)
  * Anyone hoping to port wmtop should look here first. */
 static int process_parse_stat(struct process *process)
 {
-       struct information *cur;
-
-       cur = &info;
+       struct information *cur = &info;
        char line[BUFFER_LEN] = { 0 }, filename[BUFFER_LEN], procname[BUFFER_LEN];
        int ps;
        unsigned long user_time = 0;