diff --git a/src/session.c b/src/session.c index d55732f2..2af8fd09 100644 --- a/src/session.c +++ b/src/session.c @@ -415,7 +415,19 @@ static WSavedState *getWindowState(WScreen * scr, WMPropList * win_state) return state; } -#define SAME(x, y) (((x) && (y) && !strcmp((x), (y))) || (!(x) && !(y))) +static inline int is_same(const char *x, const char *y) +{ + if ((x == NULL) && (y == NULL)) + return 1; + + if ((x == NULL) || (y == NULL)) + return 0; + + if (strcmp(x, y) == 0) + return 1; + else + return 0; +} void wSessionRestoreState(WScreen *scr) { @@ -503,8 +515,10 @@ void wSessionRestoreState(WScreen *scr) if (dock != NULL) { for (j = 0; j < dock->max_icons; j++) { btn = dock->icon_array[j]; - if (btn && SAME(instance, btn->wm_instance) && - SAME(class, btn->wm_class) && SAME(command, btn->command) && !btn->launching) { + if (btn && is_same(instance, btn->wm_instance) && + is_same(class, btn->wm_class) && + is_same(command, btn->command) && + !btn->launching) { found = 1; break; } diff --git a/src/window.c b/src/window.c index 121cd168..7cbad9cf 100644 --- a/src/window.c +++ b/src/window.c @@ -2621,7 +2621,19 @@ WMagicNumber wWindowAddSavedState(const char *instance, const char *class, return wstate; } -#define SAME(x, y) (((x) && (y) && !strcmp((x), (y))) || (!(x) && !(y))) +static inline int is_same(const char *x, const char *y) +{ + if ((x == NULL) && (y == NULL)) + return 1; + + if ((x == NULL) || (y == NULL)) + return 0; + + if (strcmp(x, y) == 0) + return 1; + else + return 0; +} WMagicNumber wWindowGetSavedState(Window win) { @@ -2637,8 +2649,9 @@ WMagicNumber wWindowGetSavedState(Window win) if (PropGetWMClass(win, &class, &instance)) { while (wstate) { - if (SAME(instance, wstate->instance) && - SAME(class, wstate->class) && SAME(command, wstate->command)) { + if (is_same(instance, wstate->instance) && + is_same(class, wstate->class) && + is_same(command, wstate->command)) { break; } wstate = wstate->next;