From e9af2d1b53b0ad4a0cf1480d496a1800701d0d09 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Sun, 22 May 2011 16:49:34 +0000 Subject: [PATCH] E: Calculate size once and reuse. Also, fix compiler warning about signed & unsigned int comparision. SVN revision: 59594 --- src/bin/e_hints.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/bin/e_hints.c b/src/bin/e_hints.c index 578347c1b..b0b63d0b2 100644 --- a/src/bin/e_hints.c +++ b/src/bin/e_hints.c @@ -1431,19 +1431,25 @@ EAPI void e_hints_window_e_state_get(E_Border *bd) { /* Remember to update the count if we add more states! */ - Ecore_X_Atom state[1]; - int num, i; + Ecore_X_Atom state[1]; + int num = 0, i = 0; + int size = 0; - memset(state, 0, sizeof(state)); - num = ecore_x_window_prop_card32_get(bd->client.win, E_ATOM_WINDOW_STATE, - state, sizeof(state) / sizeof(state[0])); /* ugly, but avoids possible future overflow if more states are added */ - if (!num) return; + memset(state, 0, sizeof(state)); - for (i = 0; (i < num) && (i < sizeof(state) / sizeof(state[0])); i++) - { - if (state[i] == E_ATOM_WINDOW_STATE_CENTERED) - bd->client.e.state.centered = 1; - } + /* ugly, but avoids possible future overflow if more states are added */ + size = (sizeof(state) / sizeof(state[0])); + + num = + ecore_x_window_prop_card32_get(bd->client.win, E_ATOM_WINDOW_STATE, + state, size); + if (!num) return; + + for (i = 0; (i < num) && (i < size); i++) + { + if (state[i] == E_ATOM_WINDOW_STATE_CENTERED) + bd->client.e.state.centered = 1; + } } EAPI void