1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-06 16:25:50 +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

@@ -1102,7 +1102,7 @@ static void previewClick(XEvent * event, void *clientData)
switch (panel->oldTabItem) {
case 0:
for (i = 0; i < sizeof(previewPositions) / sizeof(WMRect); i++) {
for (i = 0; i < sizeof(previewPositions) / sizeof(previewPositions[0]); i++) {
if (event->xbutton.x >= previewPositions[i].pos.x
&& event->xbutton.y >= previewPositions[i].pos.y
&& event->xbutton.x < previewPositions[i].pos.x

View File

@@ -608,13 +608,13 @@ static void createPanel(Panel * p)
WMResizeWidget(panel->wheelP, 135, 20);
WMMoveWidget(panel->wheelP, 95, 129);
for (i = 0; i < sizeof(buttonActions) / sizeof(char *); i++) {
for (i = 0; i < sizeof(buttonActions) / sizeof(buttonActions[0]); i++) {
WMAddPopUpButtonItem(panel->button1P, buttonActions[i]);
WMAddPopUpButtonItem(panel->button2P, buttonActions[i]);
WMAddPopUpButtonItem(panel->button3P, buttonActions[i]);
}
for (i = 0; i < sizeof(wheelActions) / sizeof(char *); i++) {
for (i = 0; i < sizeof(wheelActions) / sizeof(wheelActions[0]); i++) {
WMAddPopUpButtonItem(panel->wheelP, wheelActions[i]);
}

View File

@@ -81,7 +81,7 @@ static void showData(_Panel * panel)
str = "center";
idx = 1; /* center */
for (i = 0; i < sizeof(WSNamePositions) / sizeof(char *); i++) {
for (i = 0; i < sizeof(WSNamePositions) / sizeof(WSNamePositions[0]); i++) {
if (strcasecmp(WSNamePositions[i], str) == 0) {
idx = i;
break;