*: use {i,u}toa() where appropriate
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 6 Oct 2009 20:09:50 +0000 (22:09 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 6 Oct 2009 20:09:50 +0000 (22:09 +0200)
function                                             old     new   delta
startservice                                         377     363     -14
setari_u                                              54      40     -14
ash_main                                            1375    1361     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-42)             Total: -42 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/cal.c
editors/awk.c
miscutils/fbsplash.c
runit/runsv.c
shell/ash.c

index 9b597772ec2404bd399da05442780fc9a13e3465..ef70b0e35f0b8463f3f93bfc0ca802fe229fca54 100644 (file)
@@ -147,7 +147,7 @@ int cal_main(int argc, char **argv)
                unsigned *dp;
                char lineout[80];
 
-               sprintf(lineout, "%d", year);
+               sprintf(lineout, "%u", year);
                center(lineout,
                           (WEEK_LEN * 3 + HEAD_SEP * 2)
                           + julian * (J_WEEK_LEN * 2 + HEAD_SEP
index d15dbb3e5dedc8a6e659fd8373cdf82065366561..17244f9e69fbe30fb78a5ece0baeeea686f7a3cc 100644 (file)
@@ -765,11 +765,9 @@ static var *setvar_u(var *v, const char *value)
 /* set array element to user string */
 static void setari_u(var *a, int idx, const char *s)
 {
-       char sidx[sizeof(int)*3 + 1];
        var *v;
 
-       sprintf(sidx, "%d", idx);
-       v = findvar(iamarray(a), sidx);
+       v = findvar(iamarray(a), itoa(idx));
        setvar_u(v, s);
 }
 
index ec0f092dcb88c670d9b56300bea0ae3dac5a292e..3d225e54951cf5058b1cc2263bad539438096bfd 100644 (file)
@@ -391,9 +391,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
                num = atoi(num_buf);
                if (isdigit(num_buf[0]) && (num <= 100)) {
 #if DEBUG
-                       char strVal[10];
-                       sprintf(strVal, "%d", num);
-                       DEBUG_MESSAGE(strVal);
+                       DEBUG_MESSAGE(itoa(num));
 #endif
                        fb_drawprogressbar(num);
                }
index 4dfdd3dc114d9ed7c6db973ec686b55f4eba0ccd..8b787543f1d67c740bf30f99fa930c48acc03a11 100644 (file)
@@ -311,7 +311,6 @@ static void startservice(struct svdir *s)
        int p;
        const char *arg[4];
        char exitcode[sizeof(int)*3 + 2];
-       char sigcode[sizeof(int)*3 + 2];
 
        if (s->state == S_FINISH) {
 /* Two arguments are given to ./finish. The first one is ./run exit code,
@@ -324,13 +323,12 @@ static void startservice(struct svdir *s)
                arg[0] = "./finish";
                arg[1] = "-1";
                if (WIFEXITED(s->wstat)) {
-                       sprintf(exitcode, "%u", (int) WEXITSTATUS(s->wstat));
+                       *utoa_to_buf(WEXITSTATUS(s->wstat), exitcode, sizeof(exitcode)) = '\0';
                        arg[1] = exitcode;
                }
                //arg[2] = "0";
                //if (WIFSIGNALED(s->wstat)) {
-                       sprintf(sigcode, "%u", (int) WTERMSIG(s->wstat));
-                       arg[2] = sigcode;
+                       arg[2] = utoa(WTERMSIG(s->wstat));
                //}
                arg[3] = NULL;
        } else {
index 44d3a99a7107b2639980029ae8db5780478c4d12..2e7228d3cda3569efe2b531ee5a206de4b926e74 100644 (file)
@@ -13083,7 +13083,6 @@ init(void)
        /* from var.c: */
        {
                char **envp;
-               char ppid[sizeof(int)*3 + 2];
                const char *p;
                struct stat st1, st2;
 
@@ -13094,8 +13093,7 @@ init(void)
                        }
                }
 
-               sprintf(ppid, "%u", (unsigned) getppid());
-               setvar("PPID", ppid, 0);
+               setvar("PPID", utoa(getppid()), 0);
 
                p = lookupvar("PWD");
                if (p)