Use gcc function attribute `format' to catch bad format strings. Fix

them.  From Marc Olzheim.
Type modifier 'l' was missing in many places, probably rendering the
server useless on 64-bit hosts.
(ef_flush, ef_write, ef_extend, lwpCreate, lwpDestroy): Use conversion
specifier 'p' to print pointers.
(check_market): Fix display of loan amount.
(doland): Fix unescaped '%' (undefined behavior).
(ldump, ndump, pdump, sdump): Don't use flag '0' with conversion
specifier 's' (undefined behavior).
(dump, ldump, lost, ndump, pdump, sdump, empth_create, update_sched):
Cast time_t and pthread_t to long for printing.
(lwpStackCheck, lwpStackCheckUsed, finish_sects): Insert cast to fix
argument type on all platforms.
(prod): Remove extra argument.
(perform_mission, airdamage, retreat_land1, lwpReschedule): Format
string missed arguments.
This commit is contained in:
Markus Armbruster 2004-03-09 12:27:40 +00:00
parent 735adbf41b
commit e7d75b2279
38 changed files with 106 additions and 93 deletions

View file

@ -91,7 +91,7 @@ caploss(struct sctstr *sp, natid coun, s_char *msg)
player->dolcost -= gain;
} else
gain = 0;
wu(0, coun, "You lost $%d and they gained $%d\n", lose, gain);
wu(0, coun, "You lost $%ld and they gained $%ld\n", lose, gain);
wu(0, coun,
"Your capital has been moved to %s. You must use 'capital' to reset it.\n",
xyas(natp->nat_xcap, natp->nat_ycap, coun));

View file

@ -42,10 +42,10 @@ chkmoney(long int cost, long int cash, s_char *argp)
s_char *p;
if (cash > 0 && cost > cash / 2) {
pr("This operation will cost you $%d, and you only have $%d.\n",
pr("This operation will cost you $%ld, and you only have $%ld.\n",
cost, cash);
if (cost > cash) {
pr("You will be broke with $%d if you proceed with this command.\n", cash - cost);
pr("You will be broke with $%ld if you proceed with this command.\n", cash - cost);
}
p = getstarg(argp, "Are you sure that you want to do this? ", buf);
if (p == 0 || *p != 'y')
@ -64,7 +64,7 @@ check_cost(int looping, int cost, long int cash, int *warnedp,
if (looping && cash > 0 && player->dolcost + cost > cash
&& *warnedp < 2) {
*warnedp = 2;
pr("You will go broke! (it will cost $%d and you only have $%d)\n", cost, cash - (long)player->dolcost);
pr("You will go broke! (it will cost $%d and you only have $%ld)\n", cost, cash - (long)player->dolcost);
p = getstarg(argp, "Are you sure you wish to continue? ", buf);
if (p == 0 || *p != 'y')
return 1;
@ -73,7 +73,7 @@ check_cost(int looping, int cost, long int cash, int *warnedp,
if (looping && cash > 0 && player->dolcost > cash / 2 && *warnedp < 1) {
*warnedp = 1;
pr("WARNING. You have just spent over half of your money.\n");
pr("You started with $%d and now you only have $%d left\n", cash,
pr("You started with $%ld and now you only have $%ld left\n", cash,
cash - (long)player->dolcost);
}
return 0;

View file

@ -72,7 +72,7 @@ disloan(int n, register struct lonstr *loan)
pr("\nLoan #%d from %s to", n, cname(loan->l_loner));
pr(" %s\n", cname(loan->l_lonee));
if (loan->l_status == LS_PROPOSED) {
pr("(proposed) principal=$%d interest rate=%d%%",
pr("(proposed) principal=$%ld interest rate=%d%%",
loan->l_amtdue, loan->l_irate);
pr(" duration(days)=%d\n", loan->l_ldur);
if (loan->l_duedate < now) {
@ -103,7 +103,7 @@ disloan(int n, register struct lonstr *loan)
owe = ((double)loan->l_amtdue *
(((double)normaltime * rate + 1.0) +
((double)doubletime * rate * 2.0))) + 0.5;
pr("Amount paid to date $%d\n", loan->l_amtpaid);
pr("Amount paid to date $%ld\n", loan->l_amtpaid);
pr("Amount due (if paid now) $%.2f", owe);
if (doubletime == 0) {
pr(" (if paid on due date) $%.2f\n",

View file

@ -649,7 +649,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
"%s fires at %s %s at %s\n",
prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
mpr(victim, "%s fires at you at %s\n",
mpr(victim, "%s %s fires at you at %s\n",
cname(sp->shp_own), prship(sp), xyas(x, y, victim));
sp->shp_item[I_SHELL] = shell - gun;
@ -1473,7 +1473,7 @@ air_damage(struct emp_qelem *bombers, coord x, coord y, int mission,
if (nukedam) {
if (mission == MI_INTERDICT) {
wu(0, pp->pln_own,
"\t\tnuclear warhead does %d damage to %s %s\n",
"\t\tnuclear warhead on plane %s does %d damage to %s %s\n",
prplane(pp), nukedam, cname(victim), s);
dam += nukedam;
}

View file

@ -258,7 +258,7 @@ decode(natid cnum, long int code, void *addr, int type)
val = yrel(np, val);
break;
default:
logerror("bad type in decode: %x!\n", code & NSC_TMASK);
logerror("bad type in decode: %lx!\n", code & NSC_TMASK);
val = 0;
break;
}

View file

@ -536,10 +536,10 @@ retreat_land1(struct lndstr *lp, s_char code, int orig)
if (mines > 0 && (sect.sct_oldown != lp->lnd_own) &&
chance(DMINE_HITCHANCE(mines))) {
wu(0, lp->lnd_own,
"%s %s,\nand hit a mine while retreating!\n", prland(lp),
conditions[findcondition(code)].desc[orig], xyas(newx, newy,
lp->
lnd_own));
"%s %s,\nand hit a mine in %s while retreating!\n",
prland(lp),
conditions[findcondition(code)].desc[orig],
xyas(newx, newy, lp->lnd_own));
nreport(lp->lnd_own, N_LHIT_MINE, 0, 1);
m = MINE_LDAMAGE();
landdamage(lp, m);