1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

Changed formula for getting the number of elements in a static array

When using the formula [sizeof(array) / sizeof( x )] to get the number
of element in a static array, it is better to use array[0] for 'x'
instead of the base type of array:
 - in case the base type would change someday;
 - if the compiler were deciding to insert padding somewhere
This commit is contained in:
Christophe CURIS
2013-05-11 00:07:12 +02:00
committed by Carlos R. Mafra
parent e17a197bc4
commit 7f6699ffca
10 changed files with 18 additions and 18 deletions

View File

@@ -168,7 +168,7 @@ void FormatXError(Display * dpy, XErrorEvent * error, char *buffer, int size)
if (i > size - 100)
return;
buffer += i;
if (error->request_code >= sizeof(requestCodes) / sizeof(char *)) {
if (error->request_code >= sizeof(requestCodes) / sizeof(requestCodes[0])) {
sprintf(buffer, "\n Request code: %i\n", error->request_code);
} else {
sprintf(buffer, "\n Request code: %i %s\n", error->request_code,