From f0b19987039b9f5dc337a8ab9287a4406ea273a0 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 2 Mar 2016 18:07:59 +0100 Subject: [PATCH] Cleanups (cppcheck) --- include/textbox.h | 18 +++++++++--------- include/x11-helper.h | 1 - source/dialogs/window.c | 8 ++++---- source/helper.c | 1 - source/i3-support.c | 2 +- source/rofi.c | 12 ++++++++++-- source/view.c | 2 +- source/x11-helper.c | 7 +------ 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/textbox.h b/include/textbox.h index 3d3b8d09..e1d608e1 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -38,15 +38,15 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, - TB_MARKUP = 1 << 20, - TB_WRAP = 1 << 21, - TB_PASSWORD = 1 << 22, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, + TB_MARKUP = 1 << 20, + TB_WRAP = 1 << 21, + TB_PASSWORD = 1 << 22, } TextboxFlags; typedef enum diff --git a/include/x11-helper.h b/include/x11-helper.h index e75e0643..b0aa1eb3 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -129,7 +129,6 @@ Color color_get ( const char *const name ); void color_background ( cairo_t *d ); void color_border ( cairo_t *d ); void color_separator ( cairo_t *d ); -void color_cache_reset ( void ); void x11_helper_set_cairo_rgba ( cairo_t *d, Color col ); /*@}*/ diff --git a/source/dialogs/window.c b/source/dialogs/window.c index fcbcc8c6..cff9d052 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -455,13 +455,13 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) if ( ( c = window_client ( w ) ) ) { // final line format - unsigned int wmdesktop; - char desktop[5]; + char desktop[5]; desktop[0] = 0; - size_t len = + size_t len = ( ( c->title != NULL ) ? strlen ( c->title ) : 0 ) + ( c->class ? strlen ( c->class ) : 0 ) + classfield + 50; - char *line = g_malloc ( len ); + char *line = g_malloc ( len ); if ( !pd->config_i3_mode ) { + unsigned int wmdesktop = 0; // find client's desktop. xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *r; diff --git a/source/helper.c b/source/helper.c index e7425fa3..7f328404 100644 --- a/source/helper.c +++ b/source/helper.c @@ -579,7 +579,6 @@ int config_sanity_check ( void ) } } - PangoFontDescription * pfd = NULL; if ( config.menu_font ) { PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font ); const char *fam = pango_font_description_get_family ( pfd ); diff --git a/source/i3-support.c b/source/i3-support.c index c92fd575..6f1669b1 100644 --- a/source/i3-support.c +++ b/source/i3-support.c @@ -139,7 +139,7 @@ void i3_support_free_internals ( void ) { } -int i3_support_initialize ( void ) +int i3_support_initialize ( G_GNUC_UNUSED xcb_stuff *xcb ) { return FALSE; } diff --git a/source/rofi.c b/source/rofi.c index fbb0d53e..cc529527 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -65,7 +65,16 @@ // Pidfile. char *pidfile = NULL; const char *cache_dir = NULL; -struct xkb_stuff xkb = { NULL }; +struct xkb_stuff xkb = { + .xcb_connection = NULL, + .context = NULL, + .keymap = NULL, + .state = NULL, + .compose = { + .table = NULL, + .state = NULL + } +}; char *config_path = NULL; // Array of modi. Mode **modi = NULL; @@ -378,7 +387,6 @@ static int add_mode ( const char * token ) else{ // Report error, don't continue. fprintf ( stderr, "Invalid script switcher: %s\n", token ); - token = NULL; } } return ( index == num_modi ) ? -1 : (int) index; diff --git a/source/view.c b/source/view.c index 09857af0..0b7958f4 100644 --- a/source/view.c +++ b/source/view.c @@ -496,7 +496,7 @@ static xcb_window_t __create_window ( MenuFlags menu_flags ) { 0, 0, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS | - XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION, map }; + XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,map }; xcb_window_t box = xcb_generate_id ( xcb->connection ); xcb_create_window ( xcb->connection, diff --git a/source/x11-helper.c b/source/x11-helper.c index 58ef8444..911e62c5 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -354,6 +354,7 @@ static unsigned int x11_find_mod_mask ( xkb_stuff *xkb, ... ) mask |= 1 << i; } } + va_end ( names ); return mask; } @@ -613,12 +614,6 @@ static struct unsigned int set; } color_cache[3]; -void color_cache_reset ( void ) -{ - color_cache[BACKGROUND].set = FALSE; - color_cache[BORDER].set = FALSE; - color_cache[SEPARATOR].set = FALSE; -} void color_background ( cairo_t *d ) { if ( !color_cache[BACKGROUND].set ) {