Compilation fixes, fix a segfault on shutdown.
authorBrenden Matthews <brenden@rty.ca>
Fri, 29 May 2009 03:22:04 +0000 (21:22 -0600)
committerBrenden Matthews <brenden@rty.ca>
Fri, 29 May 2009 03:27:56 +0000 (21:27 -0600)
There was a missing 'break' in a switch/case statement which caused a
segfault on shutdown when using $if_up.

src/common.c
src/common.h
src/conky.c
src/specials.c
src/specials.h

index 7c3b017..5947384 100644 (file)
@@ -209,9 +209,11 @@ struct net_stat *get_net_stat(const char *dev)
 void clear_net_stats(void)
 {
        int i;
-       for (i = 0; i < 16; i++)
-               if (netstats[i].dev)
+       for (i = 0; i < 16; i++) {
+               if (netstats[i].dev) {
                        free(netstats[i].dev);
+               }
+       }
        memset(netstats, 0, sizeof(netstats));
 }
 
index 1c4bd40..ddf1427 100644 (file)
@@ -55,7 +55,7 @@ struct dns_data {
 void free_dns_data(void);
 
 struct net_stat {
-        const char *dev;
+        char *dev;
         int up;
         long long last_read_recv, last_read_trans;
         long long recv, trans;
index 7ac8988..26ec36f 100644 (file)
@@ -786,6 +786,7 @@ static void free_text_objects(struct text_object *root, int internal)
                        case OBJ_if_up:
                                free(data.ifblock.s);
                                free(data.ifblock.str);
+                               break;
 #endif
 #ifdef XMMS2
                        case OBJ_xmms2_artist:
@@ -1402,8 +1403,9 @@ static struct text_object *construct_text_object(const char *s,
                if (!arg) {
                        ERR("if_up needs an argument");
                        obj->data.ifblock.s = 0;
-               } else
+               } else {
                        obj->data.ifblock.s = strndup(arg, text_buffer_size);
+               }
 #endif
 #if defined(__OpenBSD__)
        END OBJ(obsd_sensors_temp, 0)
@@ -7018,8 +7020,6 @@ static void clean_up(void)
 #endif /* HAVE_LUA */
 
        if (specials) {
-               unsigned int i;
-
                for (i = 0; i < special_count; i++) {
                        if (specials[i].type == GRAPH) {
                                free(specials[i].graph);
index be1e562..a68d169 100644 (file)
 #include <math.h>
 
 /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */
-unsigned int max_specials = MAX_SPECIALS_DEFAULT;
+int max_specials = MAX_SPECIALS_DEFAULT;
 
 /* create specials array on heap instead of stack with introduction of
  * max_specials */
 struct special_t *specials = NULL;
 
-unsigned int special_count;
+int special_count;
 
 int default_bar_width = 0, default_bar_height = 6;
 #ifdef X11
index d9ba3f8..d46e1ab 100644 (file)
@@ -74,7 +74,7 @@ struct special_t {
 
 /* direct access to the registered specials (FIXME: bad encapsulation) */
 extern struct special_t *specials;
-extern unsigned int special_count;
+extern int special_count;
 
 extern int default_bar_width;
 extern int default_bar_height;
@@ -86,7 +86,7 @@ extern int default_gauge_height;
 #endif
 
 /* max number of specials allowed (TODO: use linked list instead) */
-extern unsigned int max_specials;
+extern int max_specials;
 
 #ifdef X11
 /* scanning special arguments */