aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-05-19 02:39:45 +0800
committerBen Hutchings <ben@decadent.org.uk>2020-03-28 21:42:55 +0000
commit2b71087f65f966488d55fc32b53255508d1a5e4c (patch)
treea38caf40633e2ef8ebcd3cfa604a24ae5dd116a9
parente177d47fdffd61bdd3f4e254d73653cda5454c07 (diff)
downloadklibc-2b71087f65f966488d55fc32b53255508d1a5e4c.tar.gz
[klibc] dash: jobs: Replace some uses of fmtstr with stpcpy/stpncpy
[ dash commit 15a60c2357f772ccf953772859e8f9fc124442e2 ] 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: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/dash/jobs.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c
index 2c27715328b39..9e7244e100232 100644
--- a/usr/dash/jobs.c
+++ b/usr/dash/jobs.c
@@ -404,12 +404,11 @@ out:
#endif
STATIC int
-sprint_status(char *s, int status, int sigonly)
+sprint_status(char *os, int status, int sigonly)
{
- int col;
+ char *s = os;
int st;
- col = 0;
st = WEXITSTATUS(status);
if (!WIFEXITED(status)) {
#if JOBS
@@ -425,21 +424,21 @@ sprint_status(char *s, int status, int sigonly)
goto out;
#endif
}
- col = fmtstr(s, 32, strsignal(st));
+ s = stpncpy(s, strsignal(st), 32);
#ifdef WCOREDUMP
if (WCOREDUMP(status)) {
- col += fmtstr(s + col, 16, " (core dumped)");
+ s = stpcpy(s, " (core dumped)");
}
#endif
} else if (!sigonly) {
if (st)
- col = fmtstr(s, 16, "Done(%d)", st);
+ s += fmtstr(s, 16, "Done(%d)", st);
else
- col = fmtstr(s, 16, "Done");
+ s = stpcpy(s, "Done");
}
out:
- return col;
+ return s - os;
}
static void