summaryrefslogtreecommitdiffstats
path: root/hack/hack.save.c
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>2001-03-25 20:43:58 +0000
committerjsm <jsm@NetBSD.org>2001-03-25 20:43:58 +0000
commit00b8e31689c6400d8ad915067f021b8e246df989 (patch)
treeeb00203724cf2a378ca54c9419738dd06661f34c /hack/hack.save.c
parent57d9770b2eb590f5cad0b445cdbb91acb168736f (diff)
downloadbsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.tar.gz
bsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.tar.zst
bsdgames-darwin-00b8e31689c6400d8ad915067f021b8e246df989.zip
Make mostly gcc -W clean, and other cleanup:
Use const. Add __noreturn__ attributes. Add a __format__ attribute. Add __unused__ attributes. Use symbolic constants for open() and lseek(). Declare types of all function parameters; convert some function definitions to ISO C form. Ensure standard file descriptors are open on startup. Check for errors writing output of makedefs. Avoid duplicate definitions of variables.
Diffstat (limited to 'hack/hack.save.c')
-rw-r--r--hack/hack.save.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/hack/hack.save.c b/hack/hack.save.c
index 26386e70..de94db53 100644
--- a/hack/hack.save.c
+++ b/hack/hack.save.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.save.c,v 1.6 1997/10/19 16:58:57 christos Exp $ */
+/* $NetBSD: hack.save.c,v 1.7 2001/03/25 20:44:02 jsm Exp $ */
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.save.c,v 1.6 1997/10/19 16:58:57 christos Exp $");
+__RCSID("$NetBSD: hack.save.c,v 1.7 2001/03/25 20:44:02 jsm Exp $");
#endif /* not lint */
#include <signal.h>
@@ -30,7 +30,7 @@ dosave()
#ifndef NOSAVEONHANGUP
void
hangup(n)
- int n;
+ int n __attribute__((__unused__));
{
(void) dosave0(1);
exit(1);
@@ -77,7 +77,7 @@ dosave0(hu)
if (tmp == dlevel || !level_exists[tmp])
continue;
glo(tmp);
- if ((ofd = open(lock, 0)) < 0) {
+ if ((ofd = open(lock, O_RDONLY)) < 0) {
if (!hu)
pline("Error while saving: cannot read %s.", lock);
(void) close(fd);
@@ -146,7 +146,7 @@ dorecover(fd)
savelev(nfd, tmp);
(void) close(nfd);
}
- (void) lseek(fd, (off_t) 0, 0);
+ (void) lseek(fd, (off_t) 0, SEEK_SET);
getlev(fd, 0, 0);
(void) close(fd);
(void) unlink(SAVEF);
@@ -225,7 +225,7 @@ restmonchn(fd)
long differ;
mread(fd, (char *) &monbegin, sizeof(monbegin));
- differ = (char *) (&mons[0]) - (char *) (monbegin);
+ differ = (const char *) (&mons[0]) - (const char *) (monbegin);
#ifdef lint
/* suppress "used before set" warning from lint */
@@ -243,8 +243,8 @@ restmonchn(fd)
mread(fd, (char *) mtmp, (unsigned) xl + sizeof(struct monst));
if (!mtmp->m_id)
mtmp->m_id = flags.ident++;
- mtmp->data = (struct permonst *)
- ((char *) mtmp->data + differ);
+ mtmp->data = (const struct permonst *)
+ ((const char *) mtmp->data + differ);
if (mtmp->minvent)
mtmp->minvent = restobjchn(fd);
mtmp2 = mtmp;