Skip to content

Commit e6a3f9d

Browse files
authored
Merge pull request #55 from keith-packard/opt-warn-fixes
Enable optimization, fix more warnings
2 parents b0bd698 + 737834d commit e6a3f9d

File tree

11 files changed

+43
-16
lines changed

11 files changed

+43
-16
lines changed

Xkw/Hand.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ DoInputCallback(Widget gw, Action action,
556556
XkwTranslateCoordsPosition(start_location.w, gw, &w_x, &w_y);
557557
dx = w_x - start_location.x;
558558
dy = w_y - start_location.y;
559+
hand_action = HandActionStart;
559560

560561
if (dx * dx + dy * dy >= motion_min)
561562
start_location.dragging = TRUE;

Xkw/Layout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,13 @@ ComputeSizes (BoxPtr box)
739739
BoxPtr child;
740740
GlueRec stretch;
741741
GlueRec shrink;
742-
GlueRec totalGlue[2];
742+
GlueRec totalGlue[2] = { { .order = 0, .value = 0 }, { .order = 0, .value = 0} };
743743
double remainingGlue = 0.0;
744744
GluePtr glue;
745745
int size;
746746
int totalSizes;
747747
int finalSize[2];
748-
int totalChange[2];
748+
int totalChange[2] = { 0, 0 };
749749
int change;
750750
int remainingChange = 0;
751751
Bool shrinking = 0;

kcribbage/xt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ static const CardsRank CardsRankMap[] = {
388388
};
389389

390390
static void
391-
updateCards (Widget w, CARD *h, int n, CribbageCardPtr cards, BOOLEAN blank)
391+
updateCards (Widget w, CARD *h, int n, CribbageCardPtr cards, int len, BOOLEAN blank)
392392
{
393393
int i;
394394
CardsSuit suit;
@@ -424,7 +424,7 @@ updateCards (Widget w, CARD *h, int n, CribbageCardPtr cards, BOOLEAN blank)
424424
cards[i].private = CardsAddCard (w, &cards[i].card, 0, i);
425425
}
426426
}
427-
for (; i < NUM_CARDS; i++) {
427+
for (; i < len; i++) {
428428
if (cards[i].private)
429429
{
430430
CardsRemoveCard (w, cards[i].private);
@@ -452,7 +452,7 @@ UIPrintHand (CARD *h, int n, int who, BOOLEAN blank)
452452
w = widget(who);
453453
cards = Cards(who);
454454
}
455-
updateCards (w, h, n, cards, blank);
455+
updateCards (w, h, n, cards, NUM_CARDS, blank);
456456
}
457457

458458
void
@@ -476,9 +476,9 @@ UIPrintCrib (int who, CARD *card, BOOLEAN blank)
476476
ocards = compcribCards;
477477
}
478478

479-
updateCards (w, crib, 4, cards, TRUE);
480-
updateCards (ow, NULL, 0, ocards, TRUE);
481-
updateCards (deckWidget, card, 1, deckCards, blank);
479+
updateCards (w, crib, 4, cards, NUM_CARDS, TRUE);
480+
updateCards (ow, NULL, 0, ocards, NUM_CARDS, TRUE);
481+
updateCards (deckWidget, card, 1, deckCards, 1, blank);
482482
}
483483

484484
void

kmontana/montana.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ InputCallback (Widget w, XtPointer closure, XtPointer data)
707707
CardStackPtr stack = NULL;
708708
CardStackPtr startStack = NULL;
709709
int i;
710-
Boolean hintForward;
710+
Boolean hintForward = True;
711711
String type = "";
712712

713713
(void) closure;
@@ -751,6 +751,7 @@ InputCallback (Widget w, XtPointer closure, XtPointer data)
751751
else
752752
hintForward = True;
753753
break;
754+
default:
754755
case HandActionUnexpand:
755756
i = UNHINT;
756757
break;

kslyfox/slyfox.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ StackCallback (Widget w, XtPointer closure, XtPointer data)
800800
else if (game_state == GAME_DEAL) {
801801
Message(message, "Selected stack is empty.");
802802
break;
803-
}
803+
} else
804+
card = NULL;
804805
if (game_state == GAME_DEAL) {
805806
if (to_type == STACK_TYPE_ACE || to_type == STACK_TYPE_KING) {
806807
Message(message, "Can't move %P.", &card->card);

meson.build

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
project('kgames', 'c',
2323
license : 'MIT',
2424
version: '2.1',
25-
default_options: ['bindir=games', 'datadir=share', 'warning_level=3'])
25+
default_options: [
26+
'bindir=games',
27+
'datadir=share',
28+
'warning_level=3',
29+
'buildtype=debugoptimized',
30+
])
2631

2732
c_compiler = meson.get_compiler('c')
2833

@@ -85,6 +90,11 @@ c_warnings = ['-Werror=implicit-function-declaration',
8590
'-Warray-bounds',
8691
'-Wold-style-definition',
8792
'-Wno-overlength-strings',
93+
'-fstack-protector-strong',
94+
'-Werror=format',
95+
'-Werror=format-security',
96+
'-Werror-date-time',
97+
'-D_FORTIFY_SOURCE=2',
8898
]
8999

90100
add_project_arguments(c_compiler.get_supported_arguments(c_warnings), language : 'c')

xmille/animate.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
211211
col = arg;
212212
break;
213213
case 1:
214+
default:
214215
w = computer_play;
215216
yForce = -HEIGHT;
216217
break;
@@ -234,6 +235,7 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
234235
w = human_play;
235236
break;
236237
case 1:
238+
default:
237239
w = computer_play;
238240
break;
239241
}
@@ -246,6 +248,7 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
246248
w = human_play;
247249
break;
248250
case 1:
251+
default:
249252
w = computer_play;
250253
break;
251254
}
@@ -258,6 +261,7 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
258261
w = human_play;
259262
break;
260263
case 1:
264+
default:
261265
w = computer_play;
262266
break;
263267
}
@@ -270,6 +274,7 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
270274
w = human_play;
271275
break;
272276
case 1:
277+
default:
273278
w = computer_play;
274279
break;
275280
}
@@ -282,25 +287,31 @@ compute_position (int player, int type, int arg, int *xp, int *yp)
282287
w = human_play;
283288
break;
284289
case 1:
290+
default:
285291
w = computer_play;
286292
break;
287293
}
288294
row = 0;
289295
col = 0;
290296
break;
291-
break;
292297
case ANIMATE_SAFETY:
293298
switch (player) {
294299
case 0:
295300
w = human_safeties;
296301
break;
297302
case 1:
303+
default:
298304
w = computer_safeties;
299305
break;
300306
}
301307
row = arg & 1;
302308
col = (arg & 2) >> 1;
303309
break;
310+
default:
311+
w = deck_hand;
312+
row = 0;
313+
col = 0;
314+
break;
304315
}
305316
HandRectangleForPos (w, row, col, &r);
306317
XtSetArg (args[0], XtNx, &x);

xmille/mille.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ main(int ac, char **av)
5050
bool restore;
5151

5252
/* Revoke setgid privileges */
53-
setregid(getgid(), getgid());
53+
if (setregid(getgid(), getgid()) < 0) {
54+
printf("setregid failed\n");
55+
exit(1);
56+
}
5457

5558
if (strcmp(av[0], "a.out") == 0) {
5659
outf = fopen("q", "w");

xmille/uiXt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ init_ui (int *argc, char **argv)
698698
Colormap def_cm;
699699
extern double animation_speed;
700700
unsigned long gcmask;
701-
Pixmap grayStipple;
701+
Pixmap grayStipple = None;
702702
Arg arg[2];
703703
Visual *visual;
704704

xreversi/genedge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int
1010
main (int argc, char ** argv)
1111
{
1212
if (argc > 1)
13-
freopen(argv[1], "w", stdout);
13+
stdout = freopen(argv[1], "w", stdout);
1414
register int i;
1515
for (board[1] = -1; board[1] <= 2; board[1]++)
1616
for (board[2] = -1; board[2] <= 2; board[2]++)

0 commit comments

Comments
 (0)