From 1a8acd32928f9c7b3196c9c233ee54a985538a43 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 17 Nov 2017 10:23:11 +0100 Subject: [PATCH 1/3] Add missing va_end()s to buffer_addvf() Not only does every va_start() need a corresponding va_end(), this is also true for va_end(). Thus, buffer_addvf() needs to call va_end(). Found by Codacy. Signed-off-by: Uli Schlachter --- common/buffer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/buffer.c b/common/buffer.c index 2bff36042..cbdd3872a 100644 --- a/common/buffer.c +++ b/common/buffer.c @@ -81,7 +81,10 @@ buffer_addvf(buffer_t *buf, const char *fmt, va_list args) len = vsnprintf(buf->s + buf->len, buf->size - buf->len, fmt, args); if (unlikely(len < 0)) + { + va_end(ap); return; + } if (len >= buf->size - buf->len) { buffer_ensure(buf, len); @@ -89,6 +92,7 @@ buffer_addvf(buffer_t *buf, const char *fmt, va_list args) } buf->len += len; buf->s[buf->len] = '\0'; + va_end(ap); } void From e7982b7aba78f6370551ba4d2d05632f1ad21ebd Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 17 Nov 2017 10:30:56 +0100 Subject: [PATCH 2/3] Reduce some variable scopes Codacy things this is a good idea... Signed-off-by: Uli Schlachter --- awesome.c | 3 +-- objects/window.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/awesome.c b/awesome.c index e780e72c0..4844a0e94 100644 --- a/awesome.c +++ b/awesome.c @@ -158,7 +158,6 @@ scan(xcb_query_tree_cookie_t tree_c) xcb_get_window_attributes_reply_t *attr_r; xcb_get_geometry_reply_t *geom_r; xcb_get_property_cookie_t prop_cookie; - long state; tree_r = xcb_query_tree_reply(globalconf.connection, tree_c, @@ -197,7 +196,7 @@ scan(xcb_query_tree_cookie_t tree_c) NULL); geom_r = xcb_get_geometry_reply(globalconf.connection, geom_wins[i], NULL); - state = xwindow_get_state_reply(state_wins[i]); + long state = xwindow_get_state_reply(state_wins[i]); if(!geom_r || !attr_r || attr_r->override_redirect || attr_r->map_state == XCB_MAP_STATE_UNMAPPED diff --git a/objects/window.c b/objects/window.c index 78465ea34..bd069c423 100644 --- a/objects/window.c +++ b/objects/window.c @@ -356,7 +356,6 @@ window_set_xproperty(lua_State *L, xcb_window_t window, int prop_idx, int value_ { xproperty_t *prop = luaA_find_xproperty(L, prop_idx); xcb_atom_t type; - uint8_t format; size_t len; uint32_t number; const void *data; @@ -365,6 +364,7 @@ window_set_xproperty(lua_State *L, xcb_window_t window, int prop_idx, int value_ { xcb_delete_property(globalconf.connection, window, prop->atom); } else { + uint8_t format; if(prop->type == PROP_STRING) { data = luaL_checklstring(L, value_idx, &len); From 7cf99719b5927671ee3de0c23378921b7309f3a6 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 17 Nov 2017 10:31:50 +0100 Subject: [PATCH 3/3] 'Fix' codacy complaining about unused value Signed-off-by: Uli Schlachter --- event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event.c b/event.c index f84b75745..935f8bc4b 100644 --- a/event.c +++ b/event.c @@ -864,7 +864,7 @@ event_handle_randr_output_change_notify(xcb_randr_notify_event_t *ev) xcb_randr_output_t output = ev->u.oc.output; uint8_t connection = ev->u.oc.connection; const char *connection_str = NULL; - xcb_randr_get_output_info_reply_t *info = NULL; + xcb_randr_get_output_info_reply_t *info; lua_State *L = globalconf_get_lua_State(); /* The following explicitly uses XCB_CURRENT_TIME since we want to know