From: Christophe CURIS <[email protected]>

The new macro 'wlengthof' from WUtil makes code easier to read than the
previous [sizeof() / sizeof([0]) ] construct.

Signed-off-by: Christophe CURIS <[email protected]>
---
 WINGs/menuparser.c        | 2 +-
 WINGs/menuparser_macros.c | 2 +-
 WINGs/wfontpanel.c        | 2 +-
 WINGs/widgets.c           | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/WINGs/menuparser.c b/WINGs/menuparser.c
index e4f616c..db0225b 100644
--- a/WINGs/menuparser.c
+++ b/WINGs/menuparser.c
@@ -596,7 +596,7 @@ static void menu_parser_condition_ifmacro(WMenuParser 
parser, Bool check_exists)
                parser->rd++;
 
        /* Add this condition to the stack of conditions */
-       if (parser->cond.depth >= sizeof(parser->cond.stack) / 
sizeof(parser->cond.stack[0])) {
+       if (parser->cond.depth >= wlengthof(parser->cond.stack)) {
                WMenuParserError(parser, _("too many nested #if sequences") );
                return;
        }
diff --git a/WINGs/menuparser_macros.c b/WINGs/menuparser_macros.c
index 2b093db..5b98ef8 100644
--- a/WINGs/menuparser_macros.c
+++ b/WINGs/menuparser_macros.c
@@ -190,7 +190,7 @@ void menu_parser_define_macro(WMenuParser parser)
                        }
                        if (*parser->rd == ')') break;
 
-                       if (macro->arg_count >= sizeof(arg_name) / 
sizeof(arg_name[0])) {
+                       if (macro->arg_count >= wlengthof(arg_name)) {
                                WMenuParserError(parser, _("too many parameters 
for macro \"%s\" definition"), macro->name);
                                wfree(macro);
                                *parser->rd = '\0'; // fake end-of-line to 
avoid warnings from remaining line content
diff --git a/WINGs/wfontpanel.c b/WINGs/wfontpanel.c
index 3f29051..0c1d3fd 100644
--- a/WINGs/wfontpanel.c
+++ b/WINGs/wfontpanel.c
@@ -442,7 +442,7 @@ static void addSizeToTypeface(Typeface * face, int size)
        if (size == 0) {
                int j;
 
-               for (j = 0; j < sizeof(scalableFontSizes) / 
sizeof(scalableFontSizes[0]); j++) {
+               for (j = 0; j < wlengthof(scalableFontSizes); j++) {
                        size = scalableFontSizes[j];
 
                        if (!WMCountInArray(face->sizes, (void *)(uintptr_t) 
size)) {
diff --git a/WINGs/widgets.c b/WINGs/widgets.c
index 7b9ffe8..75b44e7 100644
--- a/WINGs/widgets.c
+++ b/WINGs/widgets.c
@@ -550,7 +550,7 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int 
screen, RContext * c
                "_NET_WM_ICON_NAME",
                "_NET_WM_ICON",
        };
-       Atom atoms[sizeof(atomNames) / sizeof(atomNames[0])];
+       Atom atoms[wlengthof(atomNames)];
        int i;
 
        if (!initialized) {
@@ -801,9 +801,9 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int 
screen, RContext * c
        }
 
 #ifdef HAVE_XINTERNATOMS
-       XInternAtoms(display, atomNames, sizeof(atomNames) / 
sizeof(atomNames[0]), False, atoms);
+       XInternAtoms(display, atomNames, wlengthof(atomNames), False, atoms);
 #else
-       for (i = 0; i < sizeof(atomNames) / sizeof(atomNames[0]); i++) {
+       for (i = 0; i < wlengthof(atomNames); i++) {
                atoms[i] = XInternAtom(display, atomNames[i], False);
        }
 #endif
-- 
1.8.4.rc3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to