]> git.pond.sub.org Git - empserver/commitdiff
Use gcc function attribute `format' to catch bad format strings. Fix
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 9 Mar 2004 12:27:40 +0000 (12:27 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 9 Mar 2004 12:27:40 +0000 (12:27 +0000)
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.

38 files changed:
include/lwp.h
include/misc.h
include/prototypes.h
src/lib/commands/budg.c
src/lib/commands/buy.c
src/lib/commands/cons.c
src/lib/commands/demo.c
src/lib/commands/dump.c
src/lib/commands/edit.c
src/lib/commands/enli.c
src/lib/commands/fina.c
src/lib/commands/info.c
src/lib/commands/ldump.c
src/lib/commands/lost.c
src/lib/commands/nati.c
src/lib/commands/ndump.c
src/lib/commands/pdump.c
src/lib/commands/play.c
src/lib/commands/prod.c
src/lib/commands/repa.c
src/lib/commands/sdump.c
src/lib/commands/shark.c
src/lib/commands/trad.c
src/lib/common/file.c
src/lib/empthread/pthread.c
src/lib/lwp/lwp.c
src/lib/lwp/sel.c
src/lib/player/empdis.c
src/lib/player/player.c
src/lib/subs/caploss.c
src/lib/subs/chkmoney.c
src/lib/subs/disloan.c
src/lib/subs/mission.c
src/lib/subs/nstr.c
src/lib/subs/retreat.c
src/lib/update/finish.c
src/lib/update/nat.c
src/server/update.c

index 435b229aaf6419fe66a6c948dda0f25508c97139..6c409f04e30c6329c0f0e6f8a62eec3c09fa7fc9 100644 (file)
@@ -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;
 
index ecdc5e13d22fedb4fce09f8a06908ec10a0c2cad..633b65388f029d26fa07e26d8248e5ccca9ab7c3 100644 (file)
@@ -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
 
index 0abb99ef0c0bc054d32b66826df5fcaeb37e919c..ed5cefa6d365072a17ac6a1915c71e035b30f6cb 100644 (file)
@@ -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 
index 2a5de74301e1950f0f8c4c98e61740c08ec18b27..36908dabccf42a3b7216a264ea0eeecc1e8b43cc 100644 (file)
@@ -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));
index ff9593ab089437705acbcc6206301ccf8e2eafde..92f3c856c6dcafdcb7053c5af305c37c00081692 100644 (file)
@@ -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",
index e6193ad1ade0d120ee2a2e6c8910543fa71547bb..92509c97e18b8a919ed4eb28eaab755e450ba829 100644 (file)
@@ -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;
 }
 
index 74fbb71c23a7a757201b3293fab13710f57b5a64..97d4eb9b769552bd2eafe4233598e2cf86711b40 100644 (file)
@@ -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;
index 3f981349e34a73d8141873221edbba5433fc0d59..39d188da26a737d57b6a36aafa12f866ed4cc49e 100644 (file)
@@ -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");
index 77f0bcaa68ae693852febe716dd08b4611c6298a..dd154b9f449b7bb9106866e647132c1ec710cc71 100644 (file)
@@ -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;
index 36160b4a12d627eb16ee2c65f04b5faa2c6423f8..83cee7dea3c16073f19f2c6d9d8c99570b147e16 100644 (file)
@@ -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);
index 8b0c3b05869327671d37511fe1f3ac2d8ccb0f72..93aaf01fee7fda79743962da3798ac3c6ae45f41 100644 (file)
@@ -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");
index 7862276268167f7b165c09c4bd1859cc1b82af08..0139afdd7e73597d22debe4b77fcb3be966400e0 100644 (file)
@@ -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);
index fbd6cb32c47d262cde6c6f2e253d2064bdeec390..9b84819bc34c6dbb0e9a87b5e555f93f401bad4d 100644 (file)
@@ -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));
index 8b03872875fdb2a75076de6da641c5fd21808594..81596febb928369e945aa06d3d160acb716b7f87 100644 (file)
@@ -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) {
index 7c65f50a0cf99e1f8879c6feb97d76d4bfc07670..c8c0db735578ab6e8294fd5d873078c6c0968b16 100644 (file)
@@ -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]);
index 970342be1b1d796024595e9dcd589a04e790447f..680a5540a3b0c30f4b4a46d3e85d24435b555d0f 100644 (file)
@@ -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");
            }
        }
index 8f949aebdbb319d88b5a56d523062173bfe5d960..7f4cf249f920d2f2fd396f00c56318e14b5e99d3 100644 (file)
@@ -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");
index 067c63545993aece3a0e42116db23bf82b651cbb..57f6e12dbd4c627c5ecbde164403db05440dd640 100644 (file)
@@ -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
index 397a0f2865981e0cb6a1d2723504997d5b73b895..34b220704359a7d74d651146df87e94e78f9038b 100644 (file)
@@ -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;
        }
 
index 560d4c37ee6eaee89d846fba70804d0694d03e4a..24dfa3421962d661c378eb2c8fa97d6a6b549fce 100644 (file)
@@ -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;
index ed17fa49ae63ec3b6d52e5c55356ec9e13aafd18..f6778b766d1ea1fb02fc1893c98d73b1c94156d9 100644 (file)
@@ -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));
index 7c4af2ccb6b0f67a2eae24682d2287784bde829f..b9827a8fd807175c6bbc3030358877c82072b68a 100644 (file)
@@ -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);
     }
index f021d428022343bec12adf613c93bb2e0089c8bd..cb3cf04330a53b4cf9d29615b9cf04cbb43c976b 100644 (file)
@@ -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");
index 9848738f2cf6b710a81757306a7870d57ea5f5c0..3b065962db02936a161bd77cf891617ab3269da9 100644 (file)
@@ -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;
        }
     }
index 357a6106eeac2fc7c0a45ffb20f85abeabd7be2e..8eb5de799bdc66a28849bdc22de7e1511374ce03 100644 (file)
@@ -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:
index eaa29d467ac1f41ef2bf1a98e58704891e19071f..ba4f8012925dc6a8dfd6ad06d3b4c7c570af3665 100644 (file)
@@ -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
index 5f5feae110e01ad38e72d664d4948ec991e97e32..cb0433744eb4453e5e3196d890d88a60c246991e 100644 (file)
@@ -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 */
index ce6b0be263481141a4659fd03dc14cbc257ce9b6..7b15ea640424a60ea265f8b4b8ae1c0f98d8687b 100644 (file)
@@ -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;
     }
index f394d60bce1398166066204091bf55e450fc4cce..50217a9e64fe32f614fc16fd2feb6745512c1177 100644 (file)
@@ -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;
     }
index fb18e76f3703b248f9a525e89dcf7990ca9182f0..2a92f99314c8cf5464082afb736bcd03b3982b56 100644 (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));
index 8ff622e97da2dd13b4304d909851c89c97c04eb6..81655da430818642d17ee87b6b73dcef5bbd2a5a 100644 (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;
index c567bf72c34597fffbda1c519337cdc0664914de..a0b95482873ffd940de97a97af85c5fae72501d4 100644 (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",
index 2908306e47f32665ca3fe50d71b83b28114a5cb2..349b63eaf94ff4b2c327298eb2534bf0c8fe1092 100644 (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;
                }
index 1741ec22bc44c3f474c6c91432f50c42499b5f7a..6b3da7eecbf9eed45b9ea38f9726808341d005f5 100644 (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;
        }
index 8818f48487a59a7c56828609a204f84492a339d9..4149cd7593b4ded3fd482d0fd7c50eefc56df3b6 100644 (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);
index 7478cc1a927735dd7df285ad9f57b6129994eec1..bd9093e52c69a3a0be5f4e1f3c7a0ad52b0e26c4 100644 (file)
@@ -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 */
index 340cec64645c09a63ebb738ee60f0084ac086d2f..441f4208480dccccf9d07f3da7539f89509f2024 100644 (file)
@@ -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++) {
index 04ec25750d3346bdddf94a55874f4e68328a620d..24ab94a125ffe2c6a19abe0245809bcd2da32111 100644 (file)
@@ -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);