Various type and cast bits.

This commit is contained in:
nhkeni
2022-03-16 18:18:52 -04:00
parent e51026aee1
commit a64a666f78
12 changed files with 28 additions and 14 deletions

View File

@@ -279,6 +279,8 @@ typedef uchar nhsym;
declaration has been moved out of the '#else' below to avoid getting
a complaint from -Wmissing-prototypes when building with MONITOR_HEAP */
extern char *dupstr(const char *);
/* same, but return strlen(string) */
extern char *dupstr_n(const char *string, unsigned int *lenout);
/*
* MONITOR_HEAP is conditionally used for primitive memory leak debugging.

View File

@@ -150,4 +150,15 @@ dupstr(const char *string)
return strcpy((char *) alloc(strlen(string) + 1), string);
}
/* similar for reasonable size strings, but return the length of the input as well */
char *
dupstr_n(const char *string, unsigned int *lenout)
{
size_t len = strlen(string);
if(len >= LARGEST_INT)
panic("string too long");
*lenout = (unsigned int) len;
return strcpy((char *) alloc((unsigned)len + 1), string);
}
/*alloc.c*/

View File

@@ -1132,7 +1132,7 @@ adjalign(int n)
} else if (newalign > u.ualign.record) {
u.ualign.record = newalign;
if (u.ualign.record > ALIGNLIM)
u.ualign.record = ALIGNLIM;
u.ualign.record = (int)ALIGNLIM;
}
}

View File

@@ -3045,7 +3045,7 @@ status_hilite_linestr_gather_conditions(void)
int i;
struct _cond_map {
unsigned long bm;
unsigned long clratr;
unsigned int clratr;
} cond_maps[SIZE(conditions)];
(void) memset(cond_maps, 0,
@@ -3075,7 +3075,7 @@ status_hilite_linestr_gather_conditions(void)
atr &= ~HL_NONE;
if (clr != NO_COLOR || atr != HL_NONE) {
unsigned long ca = clr | (atr << 8);
unsigned int ca = clr | (atr << 8);
boolean added_condmap = FALSE;
for (j = 0; j < SIZE(conditions); j++)

View File

@@ -298,7 +298,7 @@ lib_dlb_fread(char *buf, int size, int quan, dlb *dp)
/* make sure we don't read into the next file */
if ((dp->size - dp->mark) < (size * quan))
quan = (dp->size - dp->mark) / size;
quan = (int)((dp->size - dp->mark) / size);
if (quan == 0)
return 0;
@@ -313,7 +313,7 @@ lib_dlb_fread(char *buf, int size, int quan, dlb *dp)
dp->mark += nbytes;
dp->lib->fmark += nbytes;
return nread;
return (int)nread;
}
static int

View File

@@ -11,7 +11,7 @@ static void polymorph_sink(void);
static boolean teleport_sink(void);
static void dosinkring(struct obj *);
static int drop(struct obj *);
static int menudrop_split(struct obj *, int);
static int menudrop_split(struct obj *, long);
static boolean engulfer_digests_food(struct obj *);
static int wipeoff(void);
static int menu_drop(int);
@@ -838,7 +838,7 @@ doddrop(void)
}
static int /* check callers */
menudrop_split(struct obj *otmp, int cnt)
menudrop_split(struct obj *otmp, long cnt)
{
if (cnt && cnt < otmp->quan) {
if (welded(otmp)) {

View File

@@ -1762,7 +1762,7 @@ eatcorpse(struct obj *otmp)
? herbivorous(g.youmonst.data)
: carnivorous(g.youmonst.data))
&& rn2(10)
&& ((rotted < 1) ? TRUE : !rn2(rotted+1)));
&& ((rotted < 1) ? TRUE : !rn2((int)rotted+1)));
const char *pmxnam = food_xname(otmp, FALSE);
if (!strncmpi(pmxnam, "the ", 4))

View File

@@ -3034,7 +3034,7 @@ read_config_file(const char *filename, int src)
struct _cnf_parser_state {
char *inbuf;
size_t inbufsz;
unsigned inbufsz;
int rv;
char *ep;
char *buf;

View File

@@ -520,7 +520,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|| has_dnstairs(sroom))
continue;
rmno = (sroom - g.rooms) + ROOMOFFSET;
rmno = (int)(sroom - g.rooms) + ROOMOFFSET;
/* satisfied; make a swamp */
sroom->rtype = SWAMP;

View File

@@ -235,7 +235,7 @@ monmulti(struct monst* mtmp, struct obj* otmp, struct obj* mwep)
if (ammo_and_launcher(otmp, mwep) && mwep->spe > 1)
multishot += (long) rounddiv(mwep->spe, 3);
/* Some randomness */
multishot = (long) rnd((int) multishot);
multishot = rnd((int) multishot);
/* class bonus */
multishot += multishot_class_bonus(monsndx(mtmp->data), otmp, mwep);

View File

@@ -2142,7 +2142,7 @@ drop_boulder_on_player(boolean confused, boolean helmet_protects, boolean byu, b
if (!amorphous(g.youmonst.data) && !Passes_walls
&& !noncorporeal(g.youmonst.data) && !unsolid(g.youmonst.data)) {
You("are hit by %s!", doname(otmp2));
dmg = dmgval(otmp2, &g.youmonst) * otmp2->quan;
dmg = (int) (dmgval(otmp2, &g.youmonst) * otmp2->quan);
if (uarmh && helmet_protects) {
if (is_metallic(uarmh)) {
pline("Fortunately, you are wearing a hard helmet.");
@@ -2183,7 +2183,7 @@ drop_boulder_on_monster(int x, int y, boolean confused, boolean byu)
if (mtmp && !amorphous(mtmp->data) && !passes_walls(mtmp->data)
&& !noncorporeal(mtmp->data) && !unsolid(mtmp->data)) {
struct obj *helmet = which_armor(mtmp, W_ARMH);
int mdmg;
long mdmg;
if (cansee(mtmp->mx, mtmp->my)) {
pline("%s is hit by %s!", Monnam(mtmp), doname(otmp2));

View File

@@ -327,7 +327,8 @@ check_version(struct version_info *version_data, const char *filename,
boolean
uptodate(NHFILE *nhfp, const char *name, unsigned long utdflags)
{
int rlen = 0, cmc = 0, filecmc = 0;
ssize_t rlen = 0;
int cmc = 0, filecmc = 0;
struct version_info vers_info;
boolean verbose = name ? TRUE : FALSE;
char indicator;