tAll utils now pass the valgrind test, yay ! - wmutils - X windows manipulation utilities
 (HTM) git clone git://z3bra.org/wmutils
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 14021c2836c9795c4581ff29336961a9bdbf9ec4
 (DIR) parent 4f85d7191300146a2733a85673b214e49549d2a9
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Tue, 23 Dec 2014 10:34:44 +0100
       
       All utils now pass the valgrind test, yay !
       
       Diffstat:
         M chwb.c                              |       6 +++---
         M lsw.c                               |       2 ++
         M mapw.c                              |       2 ++
         M util.c                              |       1 +
         M wattr.c                             |      13 ++++++++-----
         M wmv.c                               |       3 ++-
         M wname.c                             |       2 ++
         M wtf.c                               |      14 +++++++-------
       
       8 files changed, 27 insertions(+), 16 deletions(-)
       ---
 (DIR) diff --git a/chwb.c b/chwb.c
       t@@ -49,8 +49,6 @@ main (int argc, char **argv)
                char *argv0;
                int color,bw;
        
       -        init_xcb(&conn);
       -
                color = bw = -1;
        
                if (argc < 2)
       t@@ -63,10 +61,12 @@ main (int argc, char **argv)
                        case 'c':
                                color = strtoul(EARGF(usage(argv0)), NULL, 16);
                                break;
       -                case 'h':
       +        default:
                                usage(argv0);
                } ARGEND
        
       +        init_xcb(&conn);
       +
                /* assume remaining arguments are windows */
                while (*argv)
                        setborder(bw, color, strtoul(*argv++, NULL, 16));
 (DIR) diff --git a/lsw.c b/lsw.c
       t@@ -58,6 +58,8 @@ list_windows(xcb_window_t w, int listmask)
                        if (should_list(wc[i], listmask))
                                printf("0x%08x\n", wc[i]);
                }
       +
       +        free(wc);
        }
        
        int
 (DIR) diff --git a/mapw.c b/mapw.c
       t@@ -65,5 +65,7 @@ main(int argc, char **argv)
                }
                xcb_flush(conn);
        
       +        kill_xcb(&conn);
       +
                return 0;
        }
 (DIR) diff --git a/util.c b/util.c
       t@@ -40,6 +40,7 @@ exists(xcb_connection_t *con, xcb_window_t w)
                if (r == NULL)
                        return 0;
        
       +        free(r);
                return 1;
        }
        
 (DIR) diff --git a/wattr.c b/wattr.c
       t@@ -58,7 +58,7 @@ get_attribute(xcb_window_t w, int attr)
        int
        main(int argc, char **argv)
        {
       -        int c;
       +        int c, ret = 0;
                size_t i;
                xcb_window_t w = 0;
        
       t@@ -70,7 +70,8 @@ main(int argc, char **argv)
        
                if (argc == 2) {
                        w = strtoul(argv[1], NULL, 16);
       -                exists(conn, w) ? exit(0) : exit(1);
       +                ret = exists(conn, w) ? 0 : 1;
       +                goto end;
                }
        
                for (c=2; argv[c]; c++) {
       t@@ -90,15 +91,17 @@ main(int argc, char **argv)
                                                  break;
                                        case 'w': printf("%d", get_attribute(w, ATTR_W));
                                                  break;
       -                                case 'o': ignore(conn, w) ? exit(0) : exit(1);
       -                                case 'm': mapped(conn, w) ? exit(0) : exit(1);
       +                                case 'o': ret = ignore(conn, w) ? 0 : 1; goto end;
       +                                case 'm': ret = mapped(conn, w) ? 0 : 1; goto end;
       +                                default: kill_xcb(&conn); usage(argv[0]);
                                }
                                /* add a space if more attribute come after */
                                putc(i+1 < strlen(argv[1]) ? ' ' : '\n',stdout);
                        }
                }
        
       +end:
                kill_xcb(&conn);
        
       -        return 0;
       +        return ret;
        }
 (DIR) diff --git a/wmv.c b/wmv.c
       t@@ -37,6 +37,8 @@ center_pointer(xcb_window_t win)
        
                values[0] = XCB_STACK_MODE_ABOVE;
                xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values);
       +
       +        free(geom);
        }
        
        static void
       t@@ -77,7 +79,6 @@ move(xcb_window_t win, int x, int y)
                xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_X
                                | XCB_CONFIG_WINDOW_Y, values);
        
       -
                center_pointer(win);
                free(geom);
        }
 (DIR) diff --git a/wname.c b/wname.c
       t@@ -34,8 +34,10 @@ get_title(xcb_window_t win)
                        len = xcb_get_property_value_length(r);
                        if (!len)
                                return 1;
       +
                        printf("%.*s\n", len, (char *) xcb_get_property_value(r));
        
       +                free(r);
                        return 0;
                }
        
 (DIR) diff --git a/wtf.c b/wtf.c
       t@@ -3,6 +3,7 @@
        #include <xcb/xcb.h>
        #include <stdlib.h>
        #include <stdio.h>
       +#include <string.h>
        #include <err.h>
        
        #include "util.h"
       t@@ -23,20 +24,19 @@ main(int argc, char **argv)
        {
                xcb_window_t win;
        
       -
       -        if (argc != 2)
       +        if (argc != 2 || strncmp(argv[0], "-h", 2) == 0)
                        usage(argv[0]);
        
                init_xcb(&conn);
        
                win = strtoul(argv[1], NULL, 16);
       -        if (!win)
       -                errx(1, "could not get focused window");
        
       -        xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, win,
       -                        XCB_CURRENT_TIME);
       +        if (win) {
       +                xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, win,
       +                                XCB_CURRENT_TIME);
        
       -        xcb_flush(conn);
       +                xcb_flush(conn);
       +        }
        
                kill_xcb(&conn);
                return 0;