diff options
author | Daniel Martin <consume.noise@gmail.com> | 2017-10-27 16:11:56 +0200 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-10-30 13:45:20 -0400 |
commit | d5379b350fb63e42e604361c21ad9832b4c791b9 (patch) | |
tree | 9ff0602258e2d4afb74561614810fb8a8e0e1860 /hw/xwin | |
parent | 15a32ee5d1fffa171bb05af9a0e5b472e4af1488 (diff) |
Use ARRAY_SIZE all over the tree
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with
the ARRAY_SIZE macro from dix.h when possible. A semantic patch for
coccinelle has been used first. Additionally, a few macros have been
inlined as they had only one or two users.
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'hw/xwin')
-rw-r--r-- | hw/xwin/InitOutput.c | 6 | ||||
-rw-r--r-- | hw/xwin/glx/indirect.c | 6 | ||||
-rw-r--r-- | hw/xwin/winclipboard/internal.h | 2 | ||||
-rw-r--r-- | hw/xwin/winclipboard/wndproc.c | 2 | ||||
-rw-r--r-- | hw/xwin/winclipboard/xevents.c | 3 | ||||
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 2 |
6 files changed, 9 insertions, 12 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 168c47fc4..95fc68bea 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -111,8 +111,6 @@ static PixmapFormatRec g_PixmapFormats[] = { {32, 32, BITMAP_SCANLINE_PAD} }; -const int NUMFORMATS = sizeof(g_PixmapFormats) / sizeof(g_PixmapFormats[0]); - static const ExtensionModule xwinExtensions[] = { #ifdef GLXEXT { GlxExtensionInit, "GLX", &noGlxExtension }, @@ -932,10 +930,10 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; - pScreenInfo->numPixmapFormats = NUMFORMATS; + pScreenInfo->numPixmapFormats = ARRAY_SIZE(g_PixmapFormats); /* Describe how we want common pixmap formats padded */ - for (i = 0; i < NUMFORMATS; i++) { + for (i = 0; i < ARRAY_SIZE(g_PixmapFormats); i++) { pScreenInfo->formats[i] = g_PixmapFormats[i]; } diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c index d6640700e..fb46e1c6a 100644 --- a/hw/xwin/glx/indirect.c +++ b/hw/xwin/glx/indirect.c @@ -88,8 +88,6 @@ #include <winglobals.h> #include <indirect.h> -#define NUM_ELEMENTS(x) (sizeof(x)/ sizeof(x[1])) - /* Not yet in w32api */ #ifndef PFD_SUPPORT_DIRECTDRAW #define PFD_SUPPORT_DIRECTDRAW 0x00002000 @@ -1639,7 +1637,7 @@ fbConfigToPixelFormat(__GLXconfig * mode, PIXELFORMATDESCRIPTOR * pfdret, return 0; } -#define SET_ATTR_VALUE(attr, value) { attribList[i++] = attr; attribList[i++] = value; assert(i < NUM_ELEMENTS(attribList)); } +#define SET_ATTR_VALUE(attr, value) { attribList[i++] = attr; attribList[i++] = value; assert(i < ARRAY_SIZE(attribList)); } static int fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, @@ -2018,7 +2016,7 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen) memset(result, 0, sizeof(GLXWinConfig) * numConfigs); n = 0; -#define ADD_ATTR(a) { attrs[num_attrs++] = a; assert(num_attrs < NUM_ELEMENTS(attrs)); } +#define ADD_ATTR(a) { attrs[num_attrs++] = a; assert(num_attrs < ARRAY_SIZE(attrs)); } ADD_ATTR(WGL_DRAW_TO_WINDOW_ARB); ADD_ATTR(WGL_DRAW_TO_BITMAP_ARB); diff --git a/hw/xwin/winclipboard/internal.h b/hw/xwin/winclipboard/internal.h index d0d8fbda1..2e6b22db3 100644 --- a/hw/xwin/winclipboard/internal.h +++ b/hw/xwin/winclipboard/internal.h @@ -46,6 +46,8 @@ #define WM_WM_REINIT (WM_USER + 1) #define WM_WM_QUIT (WM_USER + 2) +#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) + /* * References to external symbols */ diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c index d289f7755..c8d0064bd 100644 --- a/hw/xwin/winclipboard/wndproc.c +++ b/hw/xwin/winclipboard/wndproc.c @@ -529,7 +529,7 @@ winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) int i,j; for (i = 0 ; data.targetList[i] != 0; i++) { - for (j = 0; j < sizeof(target_priority_table)/sizeof(struct target_priority); j ++) + for (j = 0; j < ARRAY_SIZE(target_priority_table); j ++) { if ((data.targetList[i] == target_priority_table[j].target) && (target_priority_table[j].priority < best_priority)) diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c index aee6c86a2..d4ea97fc3 100644 --- a/hw/xwin/winclipboard/xevents.c +++ b/hw/xwin/winclipboard/xevents.c @@ -267,8 +267,7 @@ winClipboardFlushXEvents(HWND hwnd, 32, PropModeReplace, (unsigned char *) atomTargetArr, - (sizeof(atomTargetArr) - / sizeof(atomTargetArr[0]))); + ARRAY_SIZE(atomTargetArr)); if (iReturn == BadAlloc || iReturn == BadAtom || iReturn == BadMatch diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index c68387d81..32bc722e2 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -1517,7 +1517,7 @@ winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) }; xcb_ewmh_set_supported(&pWMInfo->ewmh, pProcArg->dwScreen, - sizeof(supported)/sizeof(xcb_atom_t), supported); + ARRAY_SIZE(supported), supported); } else { ErrorF("winInitMultiWindowWM - xcb_ewmh_init_atoms() failed\n"); |