some lint cleanup
Mostly `gcc -Wwrite-strings' complaining about passing string
literals to safe_qbuf(). `gcc -Wformat' didn't catch the type mismatch
of formatting the return value of strlen() with %d, presumeably because
size_t is defined as unsigned int on this system and it treats int and
unsigned int as interchangeable as far as printf/scanf checking goes.
I'm not sure whether the sizeof() values being passed to safe_qbuf()
ought to have casts. Any system where size_t isn't the same width as
unsigned int is bound to support prototypes, but might possibly warn about
the implicit conversion of unsigned long (or even unsigned long long these
days) to unsigned int.
This commit is contained in:
@@ -1484,7 +1484,8 @@ E int NDECL(doloot);
|
||||
E int FDECL(use_container, (struct obj *,int));
|
||||
E int FDECL(loot_mon, (struct monst *,int *,boolean *));
|
||||
E int NDECL(dotip);
|
||||
E char *FDECL(safe_qbuf, (char *,unsigned,char *,char *,char *));
|
||||
E const char *FDECL(safe_qbuf, (const char *,unsigned,
|
||||
const char *,const char *,const char *));
|
||||
|
||||
/* ### pline.c ### */
|
||||
|
||||
|
||||
@@ -2025,7 +2025,6 @@ struct obj *otmp;
|
||||
should be incorporated here instead of in set_trap]*/
|
||||
#ifdef STEED
|
||||
if (u.usteed && P_SKILL(P_RIDING) < P_BASIC) {
|
||||
char buf[BUFSZ];
|
||||
boolean chance;
|
||||
|
||||
if (Fumbling || otmp->cursed) chance = (rnl(10) > 3);
|
||||
|
||||
24
src/pickup.c
24
src/pickup.c
@@ -1154,19 +1154,25 @@ boolean telekinesis;
|
||||
* finally using the fallback as a last resort.
|
||||
* last_restort is expected to be very short.
|
||||
*/
|
||||
char *
|
||||
const char *
|
||||
safe_qbuf(qbuf, padlength, planA, planB, last_resort)
|
||||
char *qbuf, *planA, *planB, *last_resort;
|
||||
const char *qbuf, *planA, *planB, *last_resort;
|
||||
unsigned padlength;
|
||||
{
|
||||
unsigned textleft = QBUFSZ - (strlen(qbuf) + padlength);
|
||||
if (strlen(last_resort) >= textleft) {
|
||||
impossible("safe_qbuf: last_resort too large at %d characters.",
|
||||
strlen(last_resort));
|
||||
return "";
|
||||
/* convert size_t (or int for ancient systems) to ordinary unsigned */
|
||||
unsigned len_qbuf = (unsigned)strlen(qbuf),
|
||||
len_planA = (unsigned)strlen(planA),
|
||||
len_planB = (unsigned)strlen(planB),
|
||||
len_lastR = (unsigned)strlen(last_resort);
|
||||
unsigned textleft = QBUFSZ - (len_qbuf + padlength);
|
||||
|
||||
if (len_lastR >= textleft) {
|
||||
impossible("safe_qbuf: last_resort too large at %u characters.",
|
||||
len_lastR);
|
||||
return "";
|
||||
}
|
||||
return (strlen(planA) < textleft) ? planA :
|
||||
(strlen(planB) < textleft) ? planB : last_resort;
|
||||
return (len_planA < textleft) ? planA :
|
||||
(len_planB < textleft) ? planB : last_resort;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2803,6 +2803,7 @@ drown()
|
||||
}
|
||||
#endif
|
||||
crawl_ok = FALSE;
|
||||
x = y = 0; /* lint suppression */
|
||||
/* if sleeping, wake up now so that we don't crawl out of water
|
||||
while still asleep; we can't do that the same way that waking
|
||||
due to combat is handled; note unmul() clears u.usleep */
|
||||
|
||||
Reference in New Issue
Block a user