diff --git a/include/lwp.h b/include/lwp.h index 435b229a..6c409f04 100644 --- a/include/lwp.h +++ b/include/lwp.h @@ -95,7 +95,8 @@ struct lwpSem *lwpCreateSem(char *name, int count); void lwpSignal(struct lwpSem *); void lwpWait(struct lwpSem *); void lwpSelect(void *); -void lwpStatus(struct lwpProc * proc, char *format, ...); +void lwpStatus(struct lwpProc *proc, char *format, ...) + ATTRIBUTE((format (printf, 2, 3))); extern struct lwpProc *LwpCurrent; diff --git a/include/misc.h b/include/misc.h index ecdc5e13..633b6538 100644 --- a/include/misc.h +++ b/include/misc.h @@ -68,6 +68,12 @@ struct mob_acc_globals { time_t starttime; /* When we should start updating mobility again. */ }; +#ifdef __GNUC__ +#define ATTRIBUTE(attrs) __attribute__ (attrs) +#else +#define ATTRIBUTE(attrs) +#endif + #define ANNO_KEEP_DAYS 7 /* Keep announcements around for this many days */ /* This uses a lot of thread stack with some versions of GNU libc, which can lead to nasty heap smashes (observed with 2.2.93). @@ -132,7 +138,8 @@ extern s_char *iesplur(int n); extern s_char *plur(int n, s_char *no, s_char *yes); extern s_char *getstarg(s_char *input, s_char *prompt, s_char buf[]); extern s_char *getstring(s_char *prompt, s_char buf[]); -extern s_char *prbuf(s_char *format, ...); +extern s_char *prbuf(s_char *format, ...) + ATTRIBUTE((format (printf, 1, 2))); #define MAXCHRNV 12 diff --git a/include/prototypes.h b/include/prototypes.h index 0abb99ef..ed5cefa6 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -130,7 +130,7 @@ extern int adj_units(coord, coord, natid); extern int has_helpful_engineer(coord x, coord y, natid cn); /* log.c */ extern void loginit(s_char *); -extern void logerror(s_char *, ...); +extern void logerror(s_char *, ...) ATTRIBUTE((format (printf, 1, 2))); /* maps.c */ extern int draw_map(int, s_char, int, struct nstr_sect *, int); extern int unit_map(int, int, struct nstr_sect *, s_char *); @@ -414,12 +414,16 @@ extern int pln_hitchance(struct plnstr *, int, int); extern int pln_damage(struct plnstr *, coord, coord, s_char, int *, int); extern int pln_identchance(struct plnstr *, int, int); /* pr.c */ -extern void pr(s_char *, ...); +extern void pr(s_char *, ...) ATTRIBUTE((format (printf, 1, 2))); extern void prnf(s_char *buf); -extern void pr_id(struct player *, int, s_char *, ...); -extern void pr_flash(struct player *, s_char *, ...); -extern void pr_inform(struct player *, s_char *, ...); -extern void pr_wall(s_char *, ...); +extern void pr_id(struct player *, int, s_char *, ...) + ATTRIBUTE((format (printf, 3, 4))); +extern void pr_flash(struct player *, s_char *, ...) + ATTRIBUTE((format (printf, 2, 3))); +extern void pr_inform(struct player *, s_char *, ...) + ATTRIBUTE((format (printf, 2, 3))); +extern void pr_wall(s_char *, ...) + ATTRIBUTE((format (printf, 1, 2))); extern void pr_player(struct player *pl, int id, s_char *buf); extern void pr_hilite(s_char *buf); extern void prredir(s_char *redir); @@ -429,10 +433,10 @@ extern void showvers(int vers); extern int prmptrd(s_char *prompt, s_char *str, int size); extern void prdate(void); extern void prxy(s_char *format, coord x, coord y, natid country); -extern void PR(int, s_char *, ...); +extern void PR(int, s_char *, ...) ATTRIBUTE((format (printf, 2, 3))); extern void PRdate(natid cn); extern void pr_beep(void); -extern void mpr(int, s_char *, ...); +extern void mpr(int, s_char *, ...) ATTRIBUTE((format (printf, 2, 3))); /* radmap.c */ extern int deltx(struct range *, coord); @@ -527,7 +531,7 @@ extern int trechk(register natid, register natid, int); /* wu.c */ extern void clear_telegram_is_new(natid); extern int typed_wu(natid, natid, s_char *, int); -extern int wu(natid, natid, s_char *, ...); +extern int wu(natid, natid, s_char *, ...) ATTRIBUTE((format (printf, 3, 4))); /* * src/lib/update/ *.c diff --git a/src/lib/commands/budg.c b/src/lib/commands/budg.c index 2a5de743..36908dab 100644 --- a/src/lib/commands/budg.c +++ b/src/lib/commands/budg.c @@ -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)); diff --git a/src/lib/commands/buy.c b/src/lib/commands/buy.c index ff9593ab..92f3c856 100644 --- a/src/lib/commands/buy.c +++ b/src/lib/commands/buy.c @@ -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", diff --git a/src/lib/commands/cons.c b/src/lib/commands/cons.c index e6193ad1..92509c97 100644 --- a/src/lib/commands/cons.c +++ b/src/lib/commands/cons.c @@ -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; } diff --git a/src/lib/commands/demo.c b/src/lib/commands/demo.c index 74fbb71c..97d4eb9b 100644 --- a/src/lib/commands/demo.c +++ b/src/lib/commands/demo.c @@ -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; diff --git a/src/lib/commands/dump.c b/src/lib/commands/dump.c index 3f981349..39d188da 100644 --- a/src/lib/commands/dump.c +++ b/src/lib/commands/dump.c @@ -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"); diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 77f0bcaa..dd154b9f 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -316,7 +316,7 @@ prnat(natid n) pr("Connected: %d\n", np->nat_connected); pr("Representative : %-20s\n", np->nat_pnam); pr("BTUs : %3d\t\t\t", np->nat_btu); - pr("Reserves : %5d\n", np->nat_reserve); + pr("Reserves : %5ld\n", np->nat_reserve); pr("Capital : %s\t\t", xyas(np->nat_xcap, np->nat_ycap, player->cnum)); pr("Origin : %3s\n", @@ -327,7 +327,7 @@ prnat(natid n) pr("Research : %.2f\n", np->nat_level[NAT_RLEV]); pr("Education : %.2f\t\t", np->nat_level[NAT_ELEV]); pr("Happiness : %.2f\n", np->nat_level[NAT_HLEV]); - pr("Money : $%6d\n", np->nat_money); + pr("Money : $%6ld\n", np->nat_money); pr("Telegrams : %6d\n", np->nat_tgms); if (opt_DEMANDUPDATE) pr("Updates missed : %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; diff --git a/src/lib/commands/enli.c b/src/lib/commands/enli.c index 36160b4a..83cee7de 100644 --- a/src/lib/commands/enli.c +++ b/src/lib/commands/enli.c @@ -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); diff --git a/src/lib/commands/fina.c b/src/lib/commands/fina.c index 8b0c3b05..93aaf01f 100644 --- a/src/lib/commands/fina.c +++ b/src/lib/commands/fina.c @@ -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"); diff --git a/src/lib/commands/info.c b/src/lib/commands/info.c index 78622762..0139afdd 100644 --- a/src/lib/commands/info.c +++ b/src/lib/commands/info.c @@ -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); diff --git a/src/lib/commands/ldump.c b/src/lib/commands/ldump.c index fbd6cb32..9b84819b 100644 --- a/src/lib/commands/ldump.c +++ b/src/lib/commands/ldump.c @@ -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)); diff --git a/src/lib/commands/lost.c b/src/lib/commands/lost.c index 8b038728..81596feb 100644 --- a/src/lib/commands/lost.c +++ b/src/lib/commands/lost.c @@ -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) { diff --git a/src/lib/commands/nati.c b/src/lib/commands/nati.c index 7c65f50a..c8c0db73 100644 --- a/src/lib/commands/nati.c +++ b/src/lib/commands/nati.c @@ -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]); diff --git a/src/lib/commands/ndump.c b/src/lib/commands/ndump.c index 970342be..680a5540 100644 --- a/src/lib/commands/ndump.c +++ b/src/lib/commands/ndump.c @@ -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"); } } diff --git a/src/lib/commands/pdump.c b/src/lib/commands/pdump.c index 8f949aeb..7f4cf249 100644 --- a/src/lib/commands/pdump.c +++ b/src/lib/commands/pdump.c @@ -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"); diff --git a/src/lib/commands/play.c b/src/lib/commands/play.c index 067c6354..57f6e12d 100644 --- a/src/lib/commands/play.c +++ b/src/lib/commands/play.c @@ -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 diff --git a/src/lib/commands/prod.c b/src/lib/commands/prod.c index 397a0f28..34b22070 100644 --- a/src/lib/commands/prod.c +++ b/src/lib/commands/prod.c @@ -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; } diff --git a/src/lib/commands/repa.c b/src/lib/commands/repa.c index 560d4c37..24dfa342 100644 --- a/src/lib/commands/repa.c +++ b/src/lib/commands/repa.c @@ -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; diff --git a/src/lib/commands/sdump.c b/src/lib/commands/sdump.c index ed17fa49..f6778b76 100644 --- a/src/lib/commands/sdump.c +++ b/src/lib/commands/sdump.c @@ -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)); diff --git a/src/lib/commands/shark.c b/src/lib/commands/shark.c index 7c4af2cc..b9827a8f 100644 --- a/src/lib/commands/shark.c +++ b/src/lib/commands/shark.c @@ -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); } diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c index f021d428..cb3cf043 100644 --- a/src/lib/commands/trad.c +++ b/src/lib/commands/trad.c @@ -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"); diff --git a/src/lib/common/file.c b/src/lib/common/file.c index 9848738f..3b065962 100644 --- a/src/lib/common/file.c +++ b/src/lib/common/file.c @@ -140,8 +140,8 @@ ef_flush(int type) return 0; } if (write(ep->fd, ep->cache, size) != size) { - logerror("ef_flush: %s cache write(%d, %x, %d) -> %d", - ep->name, ep->fd, ep->cache, ep->size, r); + logerror("ef_flush: %s cache write(%d, %p, %d) -> %d", + ep->name, ep->fd, (void *)ep->cache, ep->size, r); return 0; } } @@ -278,8 +278,8 @@ ef_write(int type, int id, caddr_t ptr) if (ep->prewrite) ep->prewrite(id, ptr); if ((r = write(ep->fd, ptr, ep->size)) != ep->size) { - logerror("ef_write: %s #%d write(%d, %x, %d) -> %d", - ep->name, id, ep->fd, ptr, ep->size, r); + logerror("ef_write: %s #%d write(%d, %p, %d) -> %d", + ep->name, id, ep->fd, (void *)ptr, ep->size, r); return 0; } if (id >= ep->baseid && id < ep->baseid + ep->cids) { @@ -368,8 +368,8 @@ ef_extend(int type, int count) if (ep->init) ep->init(cur, ptr); if ((r = write(ep->fd, ptr, ep->size)) != ep->size) { - logerror("ef_extend: %s +#%d write(%d, %x, %d) -> %d", - ep->name, count, ep->fd, ptr, ep->size, r); + logerror("ef_extend: %s +#%d write(%d, %p, %d) -> %d", + ep->name, count, ep->fd, (void *)ptr, ep->size, r); return 0; } } diff --git a/src/lib/empthread/pthread.c b/src/lib/empthread/pthread.c index 357a6106..8eb5de79 100644 --- a/src/lib/empthread/pthread.c +++ b/src/lib/empthread/pthread.c @@ -56,6 +56,8 @@ static char **udata; /* pointer to out global context */ static pthread_mutex_t mtx_ctxsw; /* thread in critical section */ +static void empth_status(char *format, ...) ATTRIBUTE((format (printf, 1, 2))); + static void * empth_start(void *ctx) @@ -230,7 +232,7 @@ empth_create(int prio, void (*entry)(void *), int size, int flags, strerror(eno)); goto bad; } - empth_status("new thread id is %d", t); + empth_status("new thread id is %ld", (long)t); return ctx; pthread_attr_destroy(&attr); bad: diff --git a/src/lib/lwp/lwp.c b/src/lib/lwp/lwp.c index eaa29d46..ba4f8012 100644 --- a/src/lib/lwp/lwp.c +++ b/src/lib/lwp/lwp.c @@ -170,7 +170,7 @@ lwpReschedule(void) if (LwpCurrent != nextp && !(LwpCurrent && i)) { /* restore previous context */ - lwpStatus(nextp, "switch in", nextp->pri); + lwpStatus(nextp, "switch in %d", nextp->pri); LwpCurrent = nextp; *LwpContextPtr = LwpCurrent->ud; #ifdef BOUNDS_CHECK @@ -296,8 +296,8 @@ lwpCreate(int priority, void (*entry)(void *), int size, int flags, char *name, newp->dead = 0; if (flags & LWP_STACKCHECK) lwpStackCheckInit(newp); - lwpStatus(newp, "creating process structure sbtm: %d", - (int)newp->sbtm); + lwpStatus(newp, "creating process structure sbtm: %p", + newp->sbtm); lwpReady(newp); lwpReady(LwpCurrent); #ifdef UCONTEXT @@ -316,7 +316,7 @@ lwpDestroy(struct lwpProc *proc) lwpStackCheckUsed(proc); lwpStackCheck(proc); } - lwpStatus(proc, "destroying sbtm: %d", (int)proc->sbtm); + lwpStatus(proc, "destroying sbtm: %p", proc->sbtm); proc->entry = 0; proc->ud = 0; proc->argv = 0; @@ -531,7 +531,7 @@ lwpStackCheck(struct lwpProc *newp) amt = (i + 1) * sizeof(long); } lwpStatus(newp, "Thread stack overflowed %d bytes (of %u)", - amt, newp->size - 2 * LWP_REDZONE - sizeof(stkalign_t)); + amt, newp->size - 2 * LWP_REDZONE - (int)sizeof(stkalign_t)); return (0); } for (lp = newp->lowmark, i = 0; i < LWP_REDZONE / sizeof(long); @@ -551,7 +551,7 @@ lwpStackCheck(struct lwpProc *newp) amt = (LWP_REDZONE - i + 1) * sizeof(long); } lwpStatus(newp, "Thread stack underflow %d bytes (of %u)", - amt, newp->size - 2 * LWP_REDZONE - sizeof(stkalign_t)); + amt, newp->size - 2 * LWP_REDZONE - (int)sizeof(stkalign_t)); return (0); } return (1); @@ -592,7 +592,7 @@ lwpStackCheckUsed(struct lwpProc *newp) } lwpStatus(newp, "stack use: %u bytes (of %u total)", (i * sizeof(long)) - LWP_REDZONE, - newp->size - 2 * LWP_REDZONE - sizeof(stkalign_t)); + newp->size - 2 * LWP_REDZONE - (int)sizeof(stkalign_t)); } #endif diff --git a/src/lib/lwp/sel.c b/src/lib/lwp/sel.c index 5f5feae1..cb043374 100644 --- a/src/lib/lwp/sel.c +++ b/src/lib/lwp/sel.c @@ -128,7 +128,7 @@ lwpWakeupFd(struct lwpProc *proc) void lwpSleepUntil(long int until) { - lwpStatus(LwpCurrent, "sleeping for %d sec", until - time(0)); + lwpStatus(LwpCurrent, "sleeping for %ld sec", until - time(0)); LwpCurrent->runtime = until; if (LwpSelect.maxfd == 0 && LwpSelect.delayq.head == 0) { /* select process is sleeping until first waiter arrives */ diff --git a/src/lib/player/empdis.c b/src/lib/player/empdis.c index ce6b0be2..7b15ea64 100644 --- a/src/lib/player/empdis.c +++ b/src/lib/player/empdis.c @@ -171,7 +171,7 @@ gamedown(void) return 1; } if (read(downf, buf, tgm.tel_length) != tgm.tel_length) { - logerror("bad length %d on login message", tgm.tel_length); + logerror("bad length %ld on login message", tgm.tel_length); close(downf); return 1; } diff --git a/src/lib/player/player.c b/src/lib/player/player.c index f394d60b..50217a9e 100644 --- a/src/lib/player/player.c +++ b/src/lib/player/player.c @@ -361,7 +361,7 @@ show_motd(void) return RET_FAIL; } if (read(upf, buf, tgm.tel_length) != tgm.tel_length) { - logerror("bad length %d on login message", tgm.tel_length); + logerror("bad length %ld on login message", tgm.tel_length); close(upf); return RET_FAIL; } diff --git a/src/lib/subs/caploss.c b/src/lib/subs/caploss.c index fb18e76f..2a92f993 100644 --- a/src/lib/subs/caploss.c +++ b/src/lib/subs/caploss.c @@ -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)); diff --git a/src/lib/subs/chkmoney.c b/src/lib/subs/chkmoney.c index 8ff622e9..81655da4 100644 --- a/src/lib/subs/chkmoney.c +++ b/src/lib/subs/chkmoney.c @@ -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; diff --git a/src/lib/subs/disloan.c b/src/lib/subs/disloan.c index c567bf72..a0b95482 100644 --- a/src/lib/subs/disloan.c +++ b/src/lib/subs/disloan.c @@ -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", diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 2908306e..349b63ea 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -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; } diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 1741ec22..6b3da7ee 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -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; } diff --git a/src/lib/subs/retreat.c b/src/lib/subs/retreat.c index 8818f484..4149cd75 100644 --- a/src/lib/subs/retreat.c +++ b/src/lib/subs/retreat.c @@ -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); diff --git a/src/lib/update/finish.c b/src/lib/update/finish.c index 7478cc1a..bd9093e5 100644 --- a/src/lib/update/finish.c +++ b/src/lib/update/finish.c @@ -94,10 +94,9 @@ finish_sects(int etu) return; } - logerror("Allocated '%d' bytes '%d' indices\n", - ((WORLD_X * WORLD_Y) * sizeof(struct distinfo)), - (WORLD_X * WORLD_Y)); - + logerror("Allocated '%lu' bytes '%d' indices\n", + (unsigned long)(WORLD_X * WORLD_Y * sizeof(struct distinfo)), + WORLD_X * WORLD_Y); } /* Wipe it clean */ diff --git a/src/lib/update/nat.c b/src/lib/update/nat.c index 340cec64..441f4208 100644 --- a/src/lib/update/nat.c +++ b/src/lib/update/nat.c @@ -179,7 +179,7 @@ prod_nat(int etu) levels[n][NAT_RLEV] = limit_level(levels[n][NAT_RLEV] / 1, NAT_RLEV, 0) * 1; wu((natid)0, n, - "total pop is %d, yielding %4.2f hap, %4.2f edu\n", + "total pop is %ld, yielding %4.2f hap, %4.2f edu\n", pop - 1, hap, edu); } if (ally_factor > 0.0) @@ -212,9 +212,9 @@ prod_nat(int etu) if ((sea_money[n] != 0) || (air_money[n] != 0) || (lnd_money[n] != 0)) wu((natid)0, n, - "Army delta $%d, Navy delta $%d, Air force delta $%d\n", + "Army delta $%ld, Navy delta $%ld, Air force delta $%ld\n", lnd_money[n], sea_money[n], air_money[n]); - wu((natid)0, n, "money delta was $%d for this update\n", + wu((natid)0, n, "money delta was $%ld for this update\n", np->nat_money - money[n]); if (opt_LOSE_CONTACT) { for (cn = 0; cn <= MAXNOC; cn++) { diff --git a/src/server/update.c b/src/server/update.c index 04ec2575..24ab94a1 100644 --- a/src/server/update.c +++ b/src/server/update.c @@ -81,7 +81,7 @@ update_sched(void *unused) delta += wind; } logerror("Next update at %s", ctime(&update_time)); - logerror("Next update in %d seconds", delta); + logerror("Next update in %ld seconds", (long)delta); /* sleep until update is scheduled to go off */ empth_sleep(update_time); time(&now);