diff options
author | mestre <mestre@cvs.openbsd.org> | 2016-03-16 15:00:36 +0000 |
---|---|---|
committer | mestre <mestre@cvs.openbsd.org> | 2016-03-16 15:00:36 +0000 |
commit | c7f397c233375064250a50d8cabea634e4e58188 (patch) | |
tree | edeb82894f0217297e1e3dfce5fc1d07abe43ec7 /games/snake | |
parent | 3fe9e94ac26cafe0dd5c414844cd41fdb723339f (diff) |
Prefer fseek(3) over rewind(3) since the latter although it also calls fseek
then additionally it calls clearerr(3) deliberately but we want to catch any
error that may happen and this way we couldn't catch it
OK tb@
Diffstat (limited to 'games/snake')
-rw-r--r-- | games/snake/snake.c | 5 |
1 files changed, 3 insertions, 2 deletions
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)) |