Module Name: src
Committed By: dholland
Date: Tue Sep 8 13:38:01 UTC 2009
Modified Files:
src/games/tetris: scores.c
Log Message:
Disable writing scores when built for /rescue. PR 42009
To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/games/tetris/scores.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/games/tetris/scores.c
diff -u src/games/tetris/scores.c:1.17 src/games/tetris/scores.c:1.18
--- src/games/tetris/scores.c:1.17 Mon Jun 1 04:03:26 2009
+++ src/games/tetris/scores.c Tue Sep 8 13:38:01 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.17 2009/06/01 04:03:26 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.18 2009/09/08 13:38:01 dholland Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -59,6 +59,13 @@
#include "tetris.h"
/*
+ * Allow updating the high scores unless we're built as part of /rescue.
+ */
+#ifndef RESCUEDIR
+#define ALLOW_SCORE_UPDATES
+#endif
+
+/*
* Within this code, we can hang onto one extra "high score", leaving
* room for our current score (whether or not it is high).
*
@@ -379,11 +386,14 @@
int serrno;
ssize_t result;
+#ifdef ALLOW_SCORE_UPDATES
if (fdp != NULL) {
mint = O_RDWR | O_CREAT;
human = "read/write";
lck = LOCK_EX;
- } else {
+ } else
+#endif
+ {
mint = O_RDONLY;
mstr = "r";
human = "reading";
@@ -556,6 +566,7 @@
nscores = 0;
}
+#ifdef ALLOW_SCORE_UPDATES
/*
* Paranoid write wrapper; unlike fwrite() it preserves errno.
*/
@@ -578,6 +589,7 @@
}
return 0;
}
+#endif /* ALLOW_SCORE_UPDATES */
/*
* Write the score file out.
@@ -585,6 +597,7 @@
static void
putscores(int sd)
{
+#ifdef ALLOW_SCORE_UPDATES
struct highscore_header header;
struct highscore_ondisk buf[MAXHISCORES];
int i;
@@ -618,6 +631,9 @@
return;
fail:
warnx("high scores may be damaged");
+#else
+ (void)sd;
+#endif /* ALLOW_SCORE_UPDATES */
}
/*