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:
parent
735adbf41b
commit
e7d75b2279
38 changed files with 106 additions and 93 deletions
|
@ -185,9 +185,9 @@ budg(void)
|
|||
|
||||
pr("%-17s\t%c\t", dchr[x].d_name, dchr[x].d_mnem);
|
||||
if (x == SCT_ENLIST)
|
||||
pr("%d mil \t", p_sect[x][0]);
|
||||
pr("%ld mil \t", p_sect[x][0]);
|
||||
else if (pchr[dchr[x].d_prd].p_cost != 0)
|
||||
pr("%d %-7s\t", p_sect[x][0], pchr[dchr[x].d_prd].p_sname);
|
||||
pr("%ld %-7s\t", p_sect[x][0], pchr[dchr[x].d_prd].p_sname);
|
||||
else
|
||||
pr("\t\t");
|
||||
|
||||
|
@ -198,15 +198,15 @@ budg(void)
|
|||
pr("\t");
|
||||
if (np->nat_priorities[x] != 0) {
|
||||
if ((np->nat_money + income - expenses) > 0) {
|
||||
pr("%8d", p_sect[x][1]);
|
||||
pr("%8ld", p_sect[x][1]);
|
||||
expenses += p_sect[x][1];
|
||||
} else
|
||||
pr("[%7d]", p_sect[x][1]);
|
||||
pr("[%7ld]", p_sect[x][1]);
|
||||
} else {
|
||||
if ((np->nat_money + income - expenses) > 0)
|
||||
pr("(%7d)", p_sect[x][1]);
|
||||
pr("(%7ld)", p_sect[x][1]);
|
||||
else
|
||||
pr("[(%7d)]", p_sect[x][1]);
|
||||
pr("[(%7ld)]", p_sect[x][1]);
|
||||
}
|
||||
|
||||
pr("\n");
|
||||
|
@ -266,7 +266,7 @@ budg(void)
|
|||
np->nat_priorities[PRI_PMAINT], -1 * pmaint);
|
||||
}
|
||||
if (p_sect[SCT_EFFIC][1]) {
|
||||
pr("Sector building\t\t\t\t%8d sct(s)\t\t%8d\n",
|
||||
pr("Sector building\t\t\t\t%8ld sct(s)\t\t%8ld\n",
|
||||
p_sect[SCT_EFFIC][0], p_sect[SCT_EFFIC][1]);
|
||||
expenses += p_sect[SCT_EFFIC][1];
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ budg(void)
|
|||
n ==
|
||||
1 ? opt_BIG_CITY ? "city" : "capital" : opt_BIG_CITY ?
|
||||
"cities" : "capitals");
|
||||
pr("%s maintenance\t\t%-32s%8d\n",
|
||||
pr("%s maintenance\t\t%-32s%8ld\n",
|
||||
opt_BIG_CITY ? "City" : "Capital", in, p_sect[SCT_CAPIT][1]);
|
||||
expenses += p_sect[SCT_CAPIT][1];
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ budg(void)
|
|||
pr("Income from bars\t\t%-32s%+8d\n", in, bars);
|
||||
}
|
||||
pr("Total income%s\n", dotsprintf(buf, "%+60d", income));
|
||||
pr("Balance forward\t\t\t\t\t\t %10d\n", np->nat_money);
|
||||
pr("Balance forward\t\t\t\t\t\t %10ld\n", np->nat_money);
|
||||
pr("Estimated delta\t\t\t\t\t\t %+10d\n", income - expenses);
|
||||
pr("Estimated new treasury%s\n",
|
||||
dotsprintf(buf, "%50d", np->nat_money + income - expenses));
|
||||
|
|
|
@ -301,7 +301,7 @@ check_market(void)
|
|||
nreport(comm.com_maxbidder, N_FIN_TROUBLE,
|
||||
comm.com_owner, 1);
|
||||
wu(0, comm.com_maxbidder,
|
||||
"You just took loan #%d for $%.2f to cover the cost of your purchase.\n",
|
||||
"You just took loan #%d for $%ld to cover the cost of your purchase.\n",
|
||||
j, loan.l_amtdue);
|
||||
wu(0, comm.com_owner,
|
||||
"You just extended loan #%d to %s to help with the purchase cose.\n",
|
||||
|
|
|
@ -231,7 +231,7 @@ loan_accept(struct ltcomstr *ltcp)
|
|||
pr("%s no longer has the funds.\n", cname(ltcp->proposer));
|
||||
if (lp->l_amtdue <= 0)
|
||||
return RET_FAIL;
|
||||
pr("You may borrow $%d at the same terms.\n", lp->l_amtdue);
|
||||
pr("You may borrow $%ld at the same terms.\n", lp->l_amtdue);
|
||||
}
|
||||
lender->nat_money -= lp->l_amtdue;
|
||||
putnat(lender);
|
||||
|
@ -245,7 +245,7 @@ loan_accept(struct ltcomstr *ltcp)
|
|||
return RET_FAIL;
|
||||
}
|
||||
accpt(ltcp);
|
||||
pr("You are now $%d richer (sort of).\n", lp->l_amtdue);
|
||||
pr("You are now $%ld richer (sort of).\n", lp->l_amtdue);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
|
|||
}
|
||||
pr("Total new civilians : %d\n", mil_demob);
|
||||
if (*p == 'y')
|
||||
pr("Military reserve stands at %d (up %d)\n",
|
||||
pr("Military reserve stands at %ld (up %d)\n",
|
||||
natp->nat_reserve + reserves, reserves);
|
||||
if (reserves > 0) {
|
||||
natp->nat_reserve += reserves;
|
||||
|
|
|
@ -248,7 +248,7 @@ dump(void)
|
|||
if (player->god)
|
||||
pr(" ");
|
||||
time(&now);
|
||||
pr("DUMP SECTOR %d\n", now);
|
||||
pr("DUMP SECTOR %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("x y");
|
||||
|
|
|
@ -316,7 +316,7 @@ prnat(natid n)
|
|||
pr("Connected: %d\n", np->nat_connected);
|
||||
pr("Representative <r>: %-20s\n", np->nat_pnam);
|
||||
pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
|
||||
pr("Reserves <m>: %5d\n", np->nat_reserve);
|
||||
pr("Reserves <m>: %5ld\n", np->nat_reserve);
|
||||
pr("Capital <c>: %s\t\t",
|
||||
xyas(np->nat_xcap, np->nat_ycap, player->cnum));
|
||||
pr("Origin <o>: %3s\n",
|
||||
|
@ -327,7 +327,7 @@ prnat(natid n)
|
|||
pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
|
||||
pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
|
||||
pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
|
||||
pr("Money <M>: $%6d\n", np->nat_money);
|
||||
pr("Money <M>: $%6ld\n", np->nat_money);
|
||||
pr("Telegrams <t>: %6d\n", np->nat_tgms);
|
||||
if (opt_DEMANDUPDATE)
|
||||
pr("Updates missed <U>: %d\n", np->nat_missed);
|
||||
|
@ -598,14 +598,14 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
|
|||
case 'p':
|
||||
old = sect->sct_pstage;
|
||||
new = errcheck(arg, 0, PLG_EXPOSED);
|
||||
pr("Plague stage of %s changed from %d to %d%\n",
|
||||
pr("Plague stage of %s changed from %d to %d%%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
sect->sct_pstage = new;
|
||||
break;
|
||||
case 't':
|
||||
old = sect->sct_ptime;
|
||||
new = errcheck(arg, 0, 255);
|
||||
pr("Plague time of %s changed from %d to %d%\n",
|
||||
pr("Plague time of %s changed from %d to %d%%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
sect->sct_ptime = new;
|
||||
break;
|
||||
|
@ -717,11 +717,11 @@ docountry(s_char op, int arg, s_char *p, float farg, natid nat,
|
|||
break;
|
||||
case 'm':
|
||||
benefit(nat, np->nat_reserve < arg);
|
||||
pr("Military Reserves changed from %d to %d\n",
|
||||
pr("Military Reserves changed from %ld to %d\n",
|
||||
np->nat_reserve, arg);
|
||||
if (np->nat_stat == STAT_NORM)
|
||||
wu(player->cnum, nat,
|
||||
"Military Reserves changed from %d to %d by divine intervention.\n",
|
||||
"Military Reserves changed from %ld to %d by divine intervention.\n",
|
||||
np->nat_reserve, arg);
|
||||
np->nat_reserve = arg;
|
||||
break;
|
||||
|
@ -753,9 +753,9 @@ docountry(s_char op, int arg, s_char *p, float farg, natid nat,
|
|||
np->nat_minused = arg;
|
||||
break;
|
||||
case 'M':
|
||||
pr("Money changed from %d to %d\n", np->nat_money, arg);
|
||||
pr("Money changed from %ld to %d\n", np->nat_money, arg);
|
||||
wu(player->cnum, nat,
|
||||
"Money changed from %d to %d by divine intervention.\n",
|
||||
"Money changed from %ld to %d by divine intervention.\n",
|
||||
np->nat_money, arg);
|
||||
np->nat_money = arg;
|
||||
break;
|
||||
|
|
|
@ -131,7 +131,7 @@ enli(void)
|
|||
}
|
||||
}
|
||||
pr("Total new enlistment : %d\n", totalmil);
|
||||
pr("Military reserves stand at %d\n", reserve);
|
||||
pr("Military reserves stand at %ld\n", reserve);
|
||||
if (totalmil) {
|
||||
natp->nat_reserve -= totalmil;
|
||||
putnat(natp);
|
||||
|
|
|
@ -108,7 +108,7 @@ fina(void)
|
|||
pr(" %-2d (%3d) %-8.8s (%3d) %-8.8s ", ni.cur,
|
||||
loan.l_loner, cname(loan.l_loner),
|
||||
loan.l_lonee, cname(loan.l_lonee));
|
||||
pr("%3d%% %3d %5d %7d",
|
||||
pr("%3d%% %3d %5ld %7d",
|
||||
loan.l_irate, loan.l_ldur, loan.l_amtpaid, (int)amt);
|
||||
if (now > loan.l_duedate)
|
||||
pr(" (in arrears)\n");
|
||||
|
|
|
@ -356,7 +356,7 @@ apro(void)
|
|||
free(lbp);
|
||||
|
||||
if ((nhl) > lhitlim) {
|
||||
pr("Limit of %ld lines exceeded\n", lhitlim);
|
||||
pr("Limit of %d lines exceeded\n", lhitlim);
|
||||
}
|
||||
pr("Found %s in %ld of %ld files and in %ld of %ld lines\n",
|
||||
bp, nhf, nf, nhl, nl);
|
||||
|
|
|
@ -160,7 +160,7 @@ ldump(void)
|
|||
if (player->god)
|
||||
pr(" ");
|
||||
time(&now);
|
||||
pr("DUMP LAND UNITS %d\n", now);
|
||||
pr("DUMP LAND UNITS %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("id");
|
||||
|
@ -310,7 +310,7 @@ ldump(void)
|
|||
while (field[n]) {
|
||||
switch (field[n++]) {
|
||||
case 1:
|
||||
pr(" %0.4s", lchr[(int)land.lnd_type].l_name);
|
||||
pr(" %.4s", lchr[(int)land.lnd_type].l_name);
|
||||
break;
|
||||
case 2:
|
||||
pr(" %d", xrel(np, land.lnd_x));
|
||||
|
|
|
@ -58,7 +58,7 @@ lost(void)
|
|||
prdate();
|
||||
nlost = 0;
|
||||
time(&now);
|
||||
pr("DUMP LOST ITEMS %d\n", now);
|
||||
pr("DUMP LOST ITEMS %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("owner ");
|
||||
pr("type id x y timestamp\n");
|
||||
|
@ -71,7 +71,7 @@ lost(void)
|
|||
pr("%d ", lost.lost_owner);
|
||||
pr("%d %d ", lost.lost_type, lost.lost_id);
|
||||
prxy("%d %d ", lost.lost_x, lost.lost_y, player->cnum);
|
||||
pr("%d\n", lost.lost_timestamp);
|
||||
pr("%ld\n", (long)lost.lost_timestamp);
|
||||
nlost++;
|
||||
}
|
||||
if (nlost == 0) {
|
||||
|
|
|
@ -79,7 +79,7 @@ nati(void)
|
|||
}
|
||||
}
|
||||
pr(" The treasury has $%.2f", (double)natp->nat_money);
|
||||
pr(" Military reserves: %d\n", natp->nat_reserve);
|
||||
pr(" Military reserves: %ld\n", natp->nat_reserve);
|
||||
pr("Education..........%6.2f Happiness.......%6.2f\n",
|
||||
(double)natp->nat_level[NAT_ELEV],
|
||||
(double)natp->nat_level[NAT_HLEV]);
|
||||
|
|
|
@ -58,7 +58,7 @@ ndump(void)
|
|||
if (player->god)
|
||||
pr(" ");
|
||||
time(&now);
|
||||
pr("DUMP NUKES %d\n", now);
|
||||
pr("DUMP NUKES %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("id x y num type\n");
|
||||
|
@ -76,7 +76,7 @@ ndump(void)
|
|||
pr("%d ", nuk.nuk_uid);
|
||||
prxy("%d %d", nuk.nuk_x, nuk.nuk_y, player->cnum);
|
||||
pr(" %d", nuk.nuk_types[i]);
|
||||
pr(" %0.5s", nchr[i].n_name);
|
||||
pr(" %.5s", nchr[i].n_name);
|
||||
pr("\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ pdump(void)
|
|||
if (player->god)
|
||||
pr(" ");
|
||||
time(&now);
|
||||
pr("DUMP PLANES %d\n", now);
|
||||
pr("DUMP PLANES %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("id");
|
||||
|
@ -212,7 +212,7 @@ pdump(void)
|
|||
while (field[n]) {
|
||||
switch (field[n++]) {
|
||||
case 1:
|
||||
pr(" %0.4s", plchr[(int)plane.pln_type].pl_name);
|
||||
pr(" %.4s", plchr[(int)plane.pln_type].pl_name);
|
||||
break;
|
||||
case 2:
|
||||
pr(" %d", xrel(natp, plane.pln_x));
|
||||
|
@ -285,7 +285,7 @@ pdump(void)
|
|||
break;
|
||||
case 20:
|
||||
if (plane.pln_nuketype != -1) {
|
||||
pr(" %0.5s", nchr[(int)plane.pln_nuketype].n_name);
|
||||
pr(" %.5s", nchr[(int)plane.pln_nuketype].n_name);
|
||||
break;
|
||||
} else
|
||||
pr(" N/A");
|
||||
|
|
|
@ -109,7 +109,7 @@ play_list(struct player *joe)
|
|||
com = "";
|
||||
|
||||
|
||||
pr("%-9.9s %3d %32.32s %2d:%02d %4ds %-20.20s\n",
|
||||
pr("%-9.9s %3d %32.32s %2d:%02d %4lds %-20.20s\n",
|
||||
cname(joe->cnum),
|
||||
joe->cnum,
|
||||
(player->god
|
||||
|
|
|
@ -397,7 +397,7 @@ prod(void)
|
|||
pr(" %4d mil 1.00 $%-5d%3dc",
|
||||
enlisted, enlisted * 3, enlisted);
|
||||
pr(" %3dc %4d\n",
|
||||
enlisted, maxmil, maxmil);
|
||||
enlisted, maxmil);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ repa(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
if (natp->nat_money < payment) {
|
||||
pr("You only have $%d.\n", natp->nat_money);
|
||||
pr("You only have $%ld.\n", natp->nat_money);
|
||||
return RET_FAIL;
|
||||
}
|
||||
player->dolcost += payment;
|
||||
|
@ -125,7 +125,7 @@ repa(void)
|
|||
putnat(loaner);
|
||||
(void)time(&loan.l_lastpay);
|
||||
if (owe <= payment) {
|
||||
wu(0, loan.l_loner, "Country #%d paid off loan #%d with $%d\n",
|
||||
wu(0, loan.l_loner, "Country #%d paid off loan #%d with $%ld\n",
|
||||
player->cnum, loan_num, payment);
|
||||
nreport(player->cnum, N_REPAY_LOAN, loan.l_loner, 1);
|
||||
loan.l_status = LS_FREE;
|
||||
|
|
|
@ -149,7 +149,7 @@ sdump(void)
|
|||
if (player->god)
|
||||
pr(" ");
|
||||
time(&now);
|
||||
pr("DUMP SHIPS %d\n", now);
|
||||
pr("DUMP SHIPS %ld\n", (long)now);
|
||||
if (player->god)
|
||||
pr("own ");
|
||||
pr("id");
|
||||
|
@ -282,7 +282,7 @@ sdump(void)
|
|||
while (field[n]) {
|
||||
switch (field[n++]) {
|
||||
case 1:
|
||||
pr(" %0.4s", mchr[(int)ship.shp_type].m_name);
|
||||
pr(" %.4s", mchr[(int)ship.shp_type].m_name);
|
||||
break;
|
||||
case 2:
|
||||
pr(" %d", xrel(np, ship.shp_x));
|
||||
|
|
|
@ -116,7 +116,7 @@ shark(void)
|
|||
"%s bought loan #%d. You now owe him!\n",
|
||||
cname(player->cnum), arg);
|
||||
wu(0, loan.l_loner,
|
||||
"%s bought loan #%d out from under you for %d\n",
|
||||
"%s bought loan #%d out from under you for %ld\n",
|
||||
cname(player->cnum), arg, payment);
|
||||
pr("You now own loan #%d. Go break some legs.\n", arg);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ trad(void)
|
|||
TRADE_DELAY / 3600.0 - (now - trade.trd_markettime) / 3600.0;
|
||||
if (tleft < 0.0)
|
||||
tleft = 0.0;
|
||||
pr("$%7d %2d %5.2f hrs ", trade.trd_price,
|
||||
pr("$%7ld %2d %5.2f hrs ", trade.trd_price,
|
||||
trade.trd_maxbidder, tleft);
|
||||
(void)trade_desc(&trade, &tg); /* XXX */
|
||||
pr("\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue