]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - hack/hack.shk.c
goto considered harmful
[bsdgames-darwin.git] / hack / hack.shk.c
index c24ecdc4ee6135f03955d34500fa02c0f73a42b3..7fa85b74f679e76bff099bfbd407723657ed938a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: hack.shk.c,v 1.9 2009/06/07 18:30:39 dholland Exp $    */
+/*     $NetBSD: hack.shk.c,v 1.14 2012/06/19 05:46:08 dholland Exp $   */
 
 /*
  * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -63,7 +63,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: hack.shk.c,v 1.9 2009/06/07 18:30:39 dholland Exp $");
+__RCSID("$NetBSD: hack.shk.c,v 1.14 2012/06/19 05:46:08 dholland Exp $");
 #endif                         /* not lint */
 
 #include <stdlib.h>
@@ -77,6 +77,7 @@ static void findshk(int);
 static struct bill_x *onbill(struct obj *);
 static void pay(long, struct monst *);
 static int dopayobj(struct bill_x *);
+static struct obj *bp_to_obj(struct bill_x *);
 static int getprice(struct obj *);
 static int realhunger(void);
 #endif
@@ -88,7 +89,7 @@ struct obj     *billobjs = 0;
 void
 obfree(struct obj *obj, struct obj *merge)
 {
-       free((char *) obj);
+       free(obj);
 }
 int
 inshop(void) {
@@ -236,7 +237,7 @@ setpaid(void)
                        obj->unpaid = 0;
        while ((obj = billobjs) != NULL) {
                billobjs = obj->nobj;
-               free((char *) obj);
+               free(obj);
        }
        ESHK(shopkeeper)->billct = 0;
 }
@@ -418,7 +419,7 @@ obfree(struct obj *obj, struct obj *merge)
                        *bp = bill[ESHK(shopkeeper)->billct];
                }
        }
-       free((char *) obj);
+       free(obj);
 }
 
 static void
@@ -602,7 +603,7 @@ dopayobj(struct bill_x *bp)
                        else
                                pline("Error in shopkeeper administration.");
                }
-               free((char *) obj);
+               free(obj);
        }
        return (1);
 }
@@ -629,7 +630,7 @@ paybill(void)
 }
 
 /* find obj on one of the lists */
-struct obj     *
+static struct obj *
 bp_to_obj(struct bill_x *bp)
 {
        struct obj     *obj;
@@ -816,17 +817,19 @@ doinvbill(int mode)
                        thisused = bp->price * uquan;
                        totused += thisused;
                        obj->quan = uquan;      /* cheat doname */
-                       (void) sprintf(buf, "x -  %s", doname(obj));
+                       (void) snprintf(buf, sizeof(buf),
+                                       "x -  %s", doname(obj));
                        obj->quan = oquan;      /* restore value */
                        for (cnt = 0; buf[cnt]; cnt++);
                        while (cnt < 50)
                                buf[cnt++] = ' ';
-                       (void) sprintf(&buf[cnt], " %5ld zorkmids", thisused);
+                       (void) snprintf(buf+cnt, sizeof(buf)-cnt,
+                                       " %5ld zorkmids", thisused);
                        if (page_line(buf))
                                goto quit;
                }
        }
-       (void) sprintf(buf, "Total:%50ld zorkmids", totused);
+       (void) snprintf(buf, sizeof(buf), "Total:%50ld zorkmids", totused);
        if (page_line("") || page_line(buf))
                goto quit;
        set_pager(1);
@@ -887,6 +890,7 @@ getprice(struct obj *obj)
                break;
        case CHAIN_SYM:
                pline("Strange ..., carrying a chain?");
+               /* FALLTHROUGH */
        case BALL_SYM:
                tmp = 10;
                break;
@@ -1099,8 +1103,7 @@ notonl_ok:
 
 /* He is digging in the shop. */
 void
-shopdig(fall)
-       int             fall;
+shopdig(int fall)
 {
        if (!fall) {
                if (u.utraptype == TT_PIT)