summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--games/atc/log.c8
-rw-r--r--games/hack/hack.rumors.c6
-rw-r--r--games/sail/misc.c6
-rw-r--r--games/snake/snake.c5
-rw-r--r--games/tetris/scores.c5
5 files changed, 19 insertions, 11 deletions
diff --git a/games/atc/log.c b/games/atc/log.c
index 56fb1cfddb0..efbd3b416dd 100644
--- a/games/atc/log.c
+++ b/games/atc/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.21 2015/12/31 16:50:29 mestre Exp $ */
+/* $OpenBSD: log.c,v 1.22 2016/03/16 15:00:35 mestre Exp $ */
/* $NetBSD: log.c,v 1.3 1995/03/21 15:04:21 cgd Exp $ */
/*-
@@ -223,7 +223,8 @@ log_score(int list_em)
else
puts("You made the top players list!");
qsort(score, num_scores, sizeof (*score), compar);
- rewind(score_fp);
+ if (fseek(score_fp, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
for (i = 0; i < num_scores; i++)
fprintf(score_fp, "%s %s %d %d %d\n",
score[i].name,
@@ -240,7 +241,8 @@ log_score(int list_em)
flock(fileno(score_fp), LOCK_UN);
fflush(score_fp);
fsync(fileno(score_fp));
- rewind(score_fp);
+ if (fseek(score_fp, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
printf("%2s: %-31s %-18s %4s %9s %4s\n", "#", "name",
"game", "time", "real time", "safe");
puts("-------------------------------------------------------------------------------");
diff --git a/games/hack/hack.rumors.c b/games/hack/hack.rumors.c
index 8713d71d58f..17141c6668b 100644
--- a/games/hack/hack.rumors.c
+++ b/games/hack/hack.rumors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.rumors.c,v 1.9 2016/01/09 18:33:15 mestre Exp $ */
+/* $OpenBSD: hack.rumors.c,v 1.10 2016/03/16 15:00:35 mestre Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -61,6 +61,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <err.h>
#include <stdio.h>
#include "hack.h" /* for RUMORFILE and BSD (index) */
@@ -82,7 +83,8 @@ init_rumors(FILE *rumf)
n_used_rumors = 0;
while(skipline(rumf)) n_rumors++;
- rewind(rumf);
+ if (fseek(rumf, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
i = n_rumors/CHARSZ;
usedbits = (char *) alloc((unsigned)(i+1));
for( ; i>=0; i--) usedbits[i] = 0;
diff --git a/games/sail/misc.c b/games/sail/misc.c
index 4ee63ed3298..ebb18ecc7f0 100644
--- a/games/sail/misc.c
+++ b/games/sail/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.9 2016/01/08 20:26:33 mestre Exp $ */
+/* $OpenBSD: misc.c,v 1.10 2016/03/16 15:00:35 mestre Exp $ */
/* $NetBSD: misc.c,v 1.3 1995/04/22 10:37:03 cgd Exp $ */
/*
@@ -31,6 +31,7 @@
*/
#include <ctype.h>
+#include <err.h>
#ifdef LOCK_EX
#include <fcntl.h>
#endif
@@ -211,7 +212,8 @@ logger(struct ship *s)
for (lp = &log[n]; lp < &log[NLOG]; lp++)
lp->l_name[0] = lp->l_uid = lp->l_shipnum
= lp->l_gamenum = lp->l_netpoints = 0;
- rewind(fp);
+ if (fseek(fp, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
if (persons < 0)
(void) putw(1, fp);
else
diff --git a/games/snake/snake.c b/games/snake/snake.c
index 32b6a3a8bef..42a739c158e 100644
--- a/games/snake/snake.c
+++ b/games/snake/snake.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snake.c,v 1.26 2016/03/07 12:07:57 mestre Exp $ */
+/* $OpenBSD: snake.c,v 1.27 2016/03/16 15:00:35 mestre Exp $ */
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
/*
@@ -543,7 +543,8 @@ post(int iscore, int flag)
printf("\nYour score of $%d is ranked %d of all times!\n",
iscore, rank + 1);
- rewind(sf);
+ if (fseek(sf, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
if (fwrite(scores, sizeof(scores[0]), nscores, sf) < (u_int)nscores)
err(1, "fwrite");
if (fclose(sf))
diff --git a/games/tetris/scores.c b/games/tetris/scores.c
index 285c7c7b2d3..2a8bb6b23d8 100644
--- a/games/tetris/scores.c
+++ b/games/tetris/scores.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scores.c,v 1.19 2016/01/04 17:33:24 mestre Exp $ */
+/* $OpenBSD: scores.c,v 1.20 2016/03/16 15:00:35 mestre Exp $ */
/* $NetBSD: scores.c,v 1.2 1995/04/22 07:42:38 cgd Exp $ */
/*-
@@ -191,7 +191,8 @@ savescore(int level)
* Sort & clean the scores, then rewrite.
*/
nscores = checkscores(scores, nscores);
- rewind(sf);
+ if (fseek(sf, 0L, SEEK_SET) == -1)
+ err(1, "fseek");
if (fwrite(scores, sizeof(*sp), nscores, sf) != nscores ||
fflush(sf) == EOF)
warnx("error writing scorefile: %s\n\t-- %s",