diff options
author | Denys Vlasenko | 2020-02-16 18:23:43 +0100 |
---|---|---|
committer | Denys Vlasenko | 2020-02-16 19:14:45 +0100 |
commit | 2bad3a305b5934d17e817a8fbb9c42ee04dc5a3c (patch) | |
tree | e37badceaeaeb6fc5aeeb687e0036bcef3234677 | |
parent | 3f7fb2c89ad75bbdd3b69e302124c8179c273bb4 (diff) | |
download | busybox-2bad3a305b5934d17e817a8fbb9c42ee04dc5a3c.zip busybox-2bad3a305b5934d17e817a8fbb9c42ee04dc5a3c.tar.gz |
ash: jobs: Replace some uses of fmtstr with stpcpy/stpncpy
Upstream commit:
Date: Sat, 19 May 2018 02:39:45 +0800
jobs: Replace some uses of fmtstr with stpcpy/stpncpy
Some uses of fmtstr, particularly the ones without a format string,
can be replaced with stpcpy or stpncpy. This patch does that so
we don't have to introduce unnecessary format strings in order to
silence compiler warnings.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/shell/ash.c b/shell/ash.c index a006a1c..75edebd 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4203,12 +4203,11 @@ fg_bgcmd(int argc UNUSED_PARAM, char **argv) #endif static int -sprint_status48(char *s, int status, int sigonly) +sprint_status48(char *os, int status, int sigonly) { - int col; + char *s = os; int st; - col = 0; if (!WIFEXITED(status)) { #if JOBS if (WIFSTOPPED(status)) @@ -4226,17 +4225,17 @@ sprint_status48(char *s, int status, int sigonly) } st &= 0x7f; //TODO: use bbox's get_signame? strsignal adds ~600 bytes to text+rodata - col = fmtstr(s, 32, strsignal(st)); + //s = stpncpy(s, strsignal(st), 32); //not all libc have stpncpy() + s += fmtstr(s, 32, strsignal(st)); if (WCOREDUMP(status)) { - strcpy(s + col, " (core dumped)"); - col += sizeof(" (core dumped)")-1; + s = stpcpy(s, " (core dumped)"); } } else if (!sigonly) { st = WEXITSTATUS(status); - col = fmtstr(s, 16, (st ? "Done(%d)" : "Done"), st); + s += fmtstr(s, 16, (st ? "Done(%d)" : "Done"), st); } out: - return col; + return s - os; } static int |