Hi People,

after a (quite long) abstinence from awesome, here is a bunch of
patches:

[1] -- Change CFLAGS
   adds -O1 to make -Wuninitialized work and removes -Wredundant-decls
   because it gave useless warnings on OpenBSD

[2] -- Remove compiler warnings
   GCC was complaining about attribute loss when passing (const
   void*)'s cast to (void*)'s to luaA_object_{decref,push_item,push}.
   This patch moves the casts a bit further down the call stack.

[3-5] -- Menubar
   These three patches make the menubar also look in
   /usr/local/share/applications, make it not die if no menu item
   is selected when pressing enter and silence warnings produced
   by find(1).

-- 
    Gregor Best
>From fd731341c47dadd6d8652d2a7d9420960c5840d0 Mon Sep 17 00:00:00 2001
From: Gregor Best <g...@ring0.de>
Date: Sat, 24 Nov 2012 17:54:25 +0100
Subject: [PATCH 1/5] Change CFLAGS

* Add -O1 to make -wuninitialized work
* Remote -Wredundant-decls because it gave useless warnings

Signed-off-by: Gregor Best <g...@ring0.de>
---
 awesomeConfig.cmake |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake
index 1dac9b1..92b16b9 100644
--- a/awesomeConfig.cmake
+++ b/awesomeConfig.cmake
@@ -16,10 +16,10 @@ option(COMPRESS_MANPAGES "compress manpages" ON)
 option(GENERATE_DOC "generate API documentation" ON)
 
 # {{{ CFLAGS
-add_definitions(-std=gnu99 -ggdb3 -rdynamic -fno-strict-aliasing -Wall -Wextra
+add_definitions(-O1 -std=gnu99 -ggdb3 -rdynamic -fno-strict-aliasing -Wall 
-Wextra
     -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings
     -Wsign-compare -Wunused -Wno-unused-parameter -Wuninitialized -Winit-self
-    -Wpointer-arith -Wredundant-decls -Wformat-nonliteral
+    -Wpointer-arith -Wformat-nonliteral
     -Wno-format-zero-length -Wmissing-format-attribute -Wmissing-prototypes
     -Wstrict-prototypes)
 # }}}
-- 
1.7.6

>From 12ebca5e311ea973814168088866a8836ca66438 Mon Sep 17 00:00:00 2001
From: Gregor Best <g...@ring0.de>
Date: Sat, 24 Nov 2012 17:57:02 +0100
Subject: [PATCH 2/5] Remove compiler warnings

Signed-off-by: Gregor Best <g...@ring0.de>
---
 common/luaobject.c |   12 ++++++------
 common/luaobject.h |   12 ++++++------
 dbus.c             |    2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/common/luaobject.c b/common/luaobject.c
index 5962829..118be3a 100644
--- a/common/luaobject.c
+++ b/common/luaobject.c
@@ -100,7 +100,7 @@ luaA_object_incref(lua_State *L, int tud, int oud)
  * \return A pointer to the object.
  */
 void
-luaA_object_decref(lua_State *L, int tud, void *pointer)
+luaA_object_decref(lua_State *L, int tud, const void *pointer)
 {
     if(!pointer)
         return;
@@ -109,7 +109,7 @@ luaA_object_decref(lua_State *L, int tud, void *pointer)
     /* Get the metatable */
     lua_getmetatable(L, tud);
     /* Push the pointer (key) */
-    lua_pushlightuserdata(L, pointer);
+    lua_pushlightuserdata(L, (void *) pointer);
     /* Get the number of references */
     lua_rawget(L, -2);
     /* Get the number of references and decrement it */
@@ -127,7 +127,7 @@ luaA_object_decref(lua_State *L, int tud, void *pointer)
     }
     lua_pop(L, 1);
     /* Push the pointer (key) */
-    lua_pushlightuserdata(L, pointer);
+    lua_pushlightuserdata(L, (void *) pointer);
     /* Hasn't the ref reached 0? */
     if(count)
         lua_pushinteger(L, count);
@@ -143,7 +143,7 @@ luaA_object_decref(lua_State *L, int tud, void *pointer)
     if(!count)
     {
         /* Yes? So remove it from table */
-        lua_pushlightuserdata(L, pointer);
+        lua_pushlightuserdata(L, (void *) pointer);
         /* Push nil as value */
         lua_pushnil(L);
         /* table[pointer] = nil */
@@ -222,7 +222,7 @@ signal_object_emit(lua_State *L, signal_array_t *arr, const 
char *name, int narg
         /* Push all functions and then execute, because this list can change
          * while executing funcs. */
         foreach(func, sigfound->sigfuncs)
-            luaA_object_push(L, (void *) *func);
+            luaA_object_push(L, *func);
 
         for(int i = 0; i < nbfunc; i++)
         {
@@ -267,7 +267,7 @@ luaA_object_emit_signal(lua_State *L, int oud,
         /* Push all functions and then execute, because this list can change
          * while executing funcs. */
         foreach(func, sigfound->sigfuncs)
-            luaA_object_push_item(L, oud_abs, (void *) *func);
+            luaA_object_push_item(L, oud_abs, *func);
 
         for(int i = 0; i < nbfunc; i++)
         {
diff --git a/common/luaobject.h b/common/luaobject.h
index 09b389a..f315443 100644
--- a/common/luaobject.h
+++ b/common/luaobject.h
@@ -30,7 +30,7 @@
 int luaA_settype(lua_State *, lua_class_t *);
 void luaA_object_setup(lua_State *);
 void * luaA_object_incref(lua_State *, int, int);
-void luaA_object_decref(lua_State *, int, void *);
+void luaA_object_decref(lua_State *, int, const void *);
 
 /** Store an item in the environment table of an object.
  * \param L The Lua VM state.
@@ -72,12 +72,12 @@ luaA_object_unref_item(lua_State *L, int ud, void *pointer)
  * \return The number of element pushed on stack.
  */
 static inline int
-luaA_object_push_item(lua_State *L, int ud, void *pointer)
+luaA_object_push_item(lua_State *L, int ud, const void *pointer)
 {
     /* Get env table of the object */
     luaA_getuservalue(L, ud);
     /* Push key */
-    lua_pushlightuserdata(L, pointer);
+    lua_pushlightuserdata(L, (void *) pointer);
     /* Get env.pointer */
     lua_rawget(L, -2);
     /* Remove env table */
@@ -127,7 +127,7 @@ luaA_object_ref_class(lua_State *L, int oud, lua_class_t 
*class)
  * \param oud The object index on the stack.
  */
 static inline void
-luaA_object_unref(lua_State *L, void *pointer)
+luaA_object_unref(lua_State *L, const void *pointer)
 {
     luaA_object_registry_push(L);
     luaA_object_decref(L, -1, pointer);
@@ -140,10 +140,10 @@ luaA_object_unref(lua_State *L, void *pointer)
  * \return The number of element pushed on stack.
  */
 static inline int
-luaA_object_push(lua_State *L, void *pointer)
+luaA_object_push(lua_State *L, const void *pointer)
 {
     luaA_object_registry_push(L);
-    lua_pushlightuserdata(L, pointer);
+    lua_pushlightuserdata(L, (void *) pointer);
     lua_rawget(L, -2);
     lua_remove(L, -2);
     return 1;
diff --git a/dbus.c b/dbus.c
index 99d37a4..5bc7e93 100644
--- a/dbus.c
+++ b/dbus.c
@@ -785,7 +785,7 @@ luaA_dbus_disconnect_signal(lua_State *L)
     luaA_checkfunction(L, 2);
     const void *func = lua_topointer(L, 2);
     signal_disconnect(&dbus_signals, name, func);
-    luaA_object_unref(L, (void *) func);
+    luaA_object_unref(L, func);
     return 0;
 }
 
-- 
1.7.6

>From a025cfcb7201880817f457a54772a07671dce76f Mon Sep 17 00:00:00 2001
From: Gregor Best <g...@ring0.de>
Date: Sat, 24 Nov 2012 17:57:27 +0100
Subject: [PATCH 3/5] Menubar: don't die if there's no item selected

Signed-off-by: Gregor Best <g...@ring0.de>
---
 lib/menubar/init.lua.in |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/menubar/init.lua.in b/lib/menubar/init.lua.in
index a8d6fc2..1588a70 100644
--- a/lib/menubar/init.lua.in
+++ b/lib/menubar/init.lua.in
@@ -106,6 +106,7 @@ end
 -- @param o The menu item.
 -- @return if the function processed the callback, new awful.prompt command, 
new awful.prompt prompt text.
 local function perform_action(o)
+    if not o then return end
     if o.key then
         current_category = o.key
         local new_prompt = shownitems[current_item].name .. ": "
-- 
1.7.6

>From 713b96c34827c5fb2ec4b657c9e3b0e88c6c6238 Mon Sep 17 00:00:00 2001
From: Gregor Best <g...@ring0.de>
Date: Sat, 24 Nov 2012 17:57:56 +0100
Subject: [PATCH 4/5] Menubar: also look in /usr/local/share/applications

Signed-off-by: Gregor Best <g...@ring0.de>
---
 lib/menubar/menu_gen.lua.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/menubar/menu_gen.lua.in b/lib/menubar/menu_gen.lua.in
index 2aab622..34c4d2c 100644
--- a/lib/menubar/menu_gen.lua.in
+++ b/lib/menubar/menu_gen.lua.in
@@ -19,7 +19,7 @@ local menu_gen = {}
 
 -- Specifies all directories where menubar should look for .desktop
 -- files. The search is not recursive.
-menu_gen.all_menu_dirs = { '/usr/share/applications/' }
+menu_gen.all_menu_dirs = { '/usr/share/applications/', 
'/usr/local/share/applications' }
 
 -- Specify the mapping of .desktop Categories section to the
 -- categories in the menubar. If "use" flag is set to false then any of
-- 
1.7.6

>From ecb6a49232e5dcf53bf9541de46da2141df3eb4a Mon Sep 17 00:00:00 2001
From: Gregor Best <g...@ring0.de>
Date: Sat, 24 Nov 2012 17:58:15 +0100
Subject: [PATCH 5/5] Menubar: silence find warnings

Signed-off-by: Gregor Best <g...@ring0.de>
---
 lib/menubar/utils.lua.in |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/menubar/utils.lua.in b/lib/menubar/utils.lua.in
index 40a30af..e45a8bc 100644
--- a/lib/menubar/utils.lua.in
+++ b/lib/menubar/utils.lua.in
@@ -181,7 +181,7 @@ end
 -- @return A table with all .desktop entries.
 function utils.parse_dir(dir)
     local programs = {}
-    local files = io.popen('find '.. dir ..' -maxdepth 1 -name "*.desktop"')
+    local files = io.popen('find '.. dir ..' -maxdepth 1 -name "*.desktop" 
2>/dev/null')
     for file in files:lines() do
         table.insert(programs, utils.parse(file))
     end
-- 
1.7.6

Reply via email to