Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hack Remove silly casts.
details: https://anonhg.NetBSD.org/src/rev/4a7bf89c7c9e
branches: trunk
changeset: 768032:4a7bf89c7c9e
user: dholland <dholland%NetBSD.org@localhost>
date: Sat Aug 06 20:00:33 2011 +0000
description:
Remove silly casts.
diffstat:
games/hack/extern.h | 4 ++--
games/hack/hack.engrave.c | 8 ++++----
games/hack/hack.lev.c | 44 ++++++++++++++++++++++----------------------
games/hack/hack.o_init.c | 10 +++++-----
games/hack/hack.save.c | 34 +++++++++++++++++-----------------
5 files changed, 50 insertions(+), 50 deletions(-)
diffs (297 lines):
diff -r 3585569ebf16 -r 4a7bf89c7c9e games/hack/extern.h
--- a/games/hack/extern.h Sat Aug 06 19:53:24 2011 +0000
+++ b/games/hack/extern.h Sat Aug 06 20:00:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.14 2011/05/30 03:11:15 joerg Exp $ */
+/* $NetBSD: extern.h,v 1.15 2011/08/06 20:00:33 dholland Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -202,7 +202,7 @@
void saveobjchn(int, struct obj *);
void savemonchn(int, struct monst *);
void getlev(int, int, xchar);
-void mread(int, char *, unsigned);
+void mread(int, void *, size_t);
void mklev(void);
/* hack.main.c */
diff -r 3585569ebf16 -r 4a7bf89c7c9e games/hack/hack.engrave.c
--- a/games/hack/hack.engrave.c Sat Aug 06 19:53:24 2011 +0000
+++ b/games/hack/hack.engrave.c Sat Aug 06 20:00:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.engrave.c,v 1.9 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.engrave.c,v 1.10 2011/08/06 20:00:33 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.engrave.c,v 1.9 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.engrave.c,v 1.10 2011/08/06 20:00:33 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -364,11 +364,11 @@
unsigned lth;
head_engr = 0;
while (1) {
- mread(fd, (char *) <h, sizeof(unsigned));
+ mread(fd, <h, sizeof(unsigned));
if (lth == 0)
return;
ep = (struct engr *) alloc(sizeof(struct engr) + lth);
- mread(fd, (char *) ep, sizeof(struct engr) + lth);
+ mread(fd, ep, sizeof(struct engr) + lth);
ep->nxt_engr = head_engr;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
head_engr = ep;
diff -r 3585569ebf16 -r 4a7bf89c7c9e games/hack/hack.lev.c
--- a/games/hack/hack.lev.c Sat Aug 06 19:53:24 2011 +0000
+++ b/games/hack/hack.lev.c Sat Aug 06 20:00:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.lev.c,v 1.11 2009/08/12 07:28:40 dholland Exp $ */
+/* $NetBSD: hack.lev.c,v 1.12 2011/08/06 20:00:33 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.lev.c,v 1.11 2009/08/12 07:28:40 dholland Exp $");
+__RCSID("$NetBSD: hack.lev.c,v 1.12 2011/08/06 20:00:33 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -219,8 +219,8 @@
xchar dlvl;
/* First some sanity checks */
- mread(fd, (char *) &hpid, sizeof(hpid));
- mread(fd, (char *) &dlvl, sizeof(dlvl));
+ mread(fd, &hpid, sizeof(hpid));
+ mread(fd, &dlvl, sizeof(dlvl));
if ((pid && pid != hpid) || (lev && dlvl != lev)) {
pline("Strange, this map is not as I remember it.");
pline("Somebody is trying some trickery here ...");
@@ -229,12 +229,12 @@
}
fgold = 0;
ftrap = 0;
- mread(fd, (char *) levl, sizeof(levl));
- mread(fd, (char *) &omoves, sizeof(omoves));
- mread(fd, (char *) &xupstair, sizeof(xupstair));
- mread(fd, (char *) &yupstair, sizeof(yupstair));
- mread(fd, (char *) &xdnstair, sizeof(xdnstair));
- mread(fd, (char *) &ydnstair, sizeof(ydnstair));
+ mread(fd, levl, sizeof(levl));
+ mread(fd, &omoves, sizeof(omoves));
+ mread(fd, &xupstair, sizeof(xupstair));
+ mread(fd, &yupstair, sizeof(yupstair));
+ mread(fd, &xdnstair, sizeof(xdnstair));
+ mread(fd, &ydnstair, sizeof(ydnstair));
fmon = restmonchn(fd);
@@ -266,55 +266,55 @@
setgd();
gold = newgold();
- mread(fd, (char *) gold, sizeof(struct gold));
+ mread(fd, gold, sizeof(struct gold));
while (gold->gx) {
gold->ngold = fgold;
fgold = gold;
gold = newgold();
- mread(fd, (char *) gold, sizeof(struct gold));
+ mread(fd, gold, sizeof(struct gold));
}
free((char *) gold);
trap = newtrap();
- mread(fd, (char *) trap, sizeof(struct trap));
+ mread(fd, trap, sizeof(struct trap));
while (trap->tx) {
trap->ntrap = ftrap;
ftrap = trap;
trap = newtrap();
- mread(fd, (char *) trap, sizeof(struct trap));
+ mread(fd, trap, sizeof(struct trap));
}
free((char *) trap);
fobj = restobjchn(fd);
billobjs = restobjchn(fd);
rest_engravings(fd);
#ifndef QUEST
- mread(fd, (char *) rooms, sizeof(rooms));
- mread(fd, (char *) doors, sizeof(doors));
+ mread(fd, rooms, sizeof(rooms));
+ mread(fd, doors, sizeof(doors));
#endif /* QUEST */
#ifndef NOWORM
- mread(fd, (char *) wsegs, sizeof(wsegs));
+ mread(fd, wsegs, sizeof(wsegs));
for (tmp = 1; tmp < 32; tmp++)
if (wsegs[tmp]) {
wheads[tmp] = wsegs[tmp] = wtmp = newseg();
while (1) {
- mread(fd, (char *) wtmp, sizeof(struct wseg));
+ mread(fd, wtmp, sizeof(struct wseg));
if (!wtmp->nseg)
break;
wheads[tmp]->nseg = wtmp = newseg();
wheads[tmp] = wtmp;
}
}
- mread(fd, (char *) wgrowtime, sizeof(wgrowtime));
+ mread(fd, wgrowtime, sizeof(wgrowtime));
#endif /* NOWORM */
}
void
-mread(int fd, char *buf, unsigned len)
+mread(int fd, void *buf, size_t len)
{
- int rlen;
+ ssize_t rlen;
rlen = read(fd, buf, len);
if (rlen < 0 || (size_t)rlen != len) {
- pline("Read %d instead of %u bytes.\n", rlen, len);
+ pline("Read %zd instead of %zu bytes.\n", rlen, len);
if (restoring) {
(void) unlink(SAVEF);
error("Error restoring old game.");
diff -r 3585569ebf16 -r 4a7bf89c7c9e games/hack/hack.o_init.c
--- a/games/hack/hack.o_init.c Sat Aug 06 19:53:24 2011 +0000
+++ b/games/hack/hack.o_init.c Sat Aug 06 20:00:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.o_init.c,v 1.10 2009/08/12 07:28:41 dholland Exp $ */
+/* $NetBSD: hack.o_init.c,v 1.11 2011/08/06 20:00:33 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.o_init.c,v 1.10 2009/08/12 07:28:41 dholland Exp $");
+__RCSID("$NetBSD: hack.o_init.c,v 1.11 2011/08/06 20:00:33 dholland Exp $");
#endif /* not lint */
#include <string.h>
@@ -201,11 +201,11 @@
{
int i;
unsigned len;
- mread(fd, (char *) bases, sizeof bases);
- mread(fd, (char *) objects, sizeof objects);
+ mread(fd, bases, sizeof bases);
+ mread(fd, objects, sizeof objects);
for (i = 0; i < SIZE(objects); i++)
if (objects[i].oc_uname) {
- mread(fd, (char *) &len, sizeof len);
+ mread(fd, &len, sizeof len);
objects[i].oc_uname = (char *) alloc(len);
mread(fd, objects[i].oc_uname, len);
}
diff -r 3585569ebf16 -r 4a7bf89c7c9e games/hack/hack.save.c
--- a/games/hack/hack.save.c Sat Aug 06 19:53:24 2011 +0000
+++ b/games/hack/hack.save.c Sat Aug 06 20:00:33 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hack.save.c,v 1.14 2010/02/03 15:34:38 roy Exp $ */
+/* $NetBSD: hack.save.c,v 1.15 2011/08/06 20:00:33 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hack.save.c,v 1.14 2010/02/03 15:34:38 roy Exp $");
+__RCSID("$NetBSD: hack.save.c,v 1.15 2011/08/06 20:00:33 dholland Exp $");
#endif /* not lint */
#include <signal.h>
@@ -172,7 +172,7 @@
setworn(otmp, otmp->owornmask);
fcobj = restobjchn(fd);
fallen_down = restmonchn(fd);
- mread(fd, (char *) &tmp, sizeof tmp);
+ mread(fd, &tmp, sizeof tmp);
if (tmp != (int) getuid()) { /* strange ... */
(void) close(fd);
(void) unlink(SAVEF);
@@ -180,16 +180,16 @@
restoring = FALSE;
return (0);
}
- mread(fd, (char *) &flags, sizeof(struct flag));
- mread(fd, (char *) &dlevel, sizeof dlevel);
- mread(fd, (char *) &maxdlevel, sizeof maxdlevel);
- mread(fd, (char *) &moves, sizeof moves);
- mread(fd, (char *) &u, sizeof(struct you));
+ mread(fd, &flags, sizeof(struct flag));
+ mread(fd, &dlevel, sizeof dlevel);
+ mread(fd, &maxdlevel, sizeof maxdlevel);
+ mread(fd, &moves, sizeof moves);
+ mread(fd, &u, sizeof(struct you));
if (u.ustuck)
- mread(fd, (char *) &mid, sizeof mid);
- mread(fd, (char *) pl_character, sizeof pl_character);
- mread(fd, (char *) genocided, sizeof genocided);
- mread(fd, (char *) fut_geno, sizeof fut_geno);
+ mread(fd, &mid, sizeof mid);
+ mread(fd, pl_character, sizeof pl_character);
+ mread(fd, genocided, sizeof genocided);
+ mread(fd, fut_geno, sizeof fut_geno);
restnames(fd);
while (1) {
if (read(fd, (char *) &tmp, sizeof tmp) != sizeof tmp)
@@ -247,7 +247,7 @@
struct obj *first = 0;
int xl;
while (1) {
- mread(fd, (char *) &xl, sizeof(xl));
+ mread(fd, &xl, sizeof(xl));
if (xl == -1)
break;
otmp = newobj(xl);
@@ -255,7 +255,7 @@
first = otmp;
else
otmp2->nobj = otmp;
- mread(fd, (char *) otmp, (unsigned) xl + sizeof(struct obj));
+ mread(fd, otmp, (unsigned) xl + sizeof(struct obj));
if (!otmp->o_id)
otmp->o_id = flags.ident++;
otmp2 = otmp;
@@ -277,7 +277,7 @@
struct permonst *monbegin;
long differ;
- mread(fd, (char *) &monbegin, sizeof(monbegin));
+ mread(fd, &monbegin, sizeof(monbegin));
differ = (const char *) (&mons[0]) - (const char *) (monbegin);
#ifdef lint
@@ -285,7 +285,7 @@
mtmp2 = 0;
#endif /* lint */
while (1) {
- mread(fd, (char *) &xl, sizeof(xl));
+ mread(fd, &xl, sizeof(xl));
if (xl == -1)
break;
mtmp = newmonst(xl);
@@ -293,7 +293,7 @@
first = mtmp;
else
mtmp2->nmon = mtmp;
- mread(fd, (char *) mtmp, (unsigned) xl + sizeof(struct monst));
+ mread(fd, mtmp, (unsigned) xl + sizeof(struct monst));
if (!mtmp->m_id)
mtmp->m_id = flags.ident++;
mtmp->data = (const struct permonst *)
Home |
Main Index |
Thread Index |
Old Index