summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenis Vlasenko2007-05-01 20:07:29 +0000
committerDenis Vlasenko2007-05-01 20:07:29 +0000
commitdcf4de20a1904bb31d498b6cc999a37f20b2783d (patch)
tree9c4c939bb250f37bd4f405b74723824cde1e8d7b /procps
parentf20de5bb42f9a4f2c8417f6a1a2db7e2f2cafd5b (diff)
downloadbusybox-dcf4de20a1904bb31d498b6cc999a37f20b2783d.zip
busybox-dcf4de20a1904bb31d498b6cc999a37f20b2783d.tar.gz
test: code size saving, no logic changes
ps: fix warning, make a bit smaller kill -l: make smaller & know much more signals function old new delta get_signum 121 153 +32 kill_main 826 843 +17 get_signame 44 36 -8 signals 252 224 -28 .rodata 131955 131923 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/3 up/down: 49/-68) Total: -19 bytes
Diffstat (limited to 'procps')
-rw-r--r--procps/kill.c4
-rw-r--r--procps/ps.c15
2 files changed, 12 insertions, 7 deletions
diff --git a/procps/kill.c b/procps/kill.c
index e2b029d..b325749 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -51,7 +51,9 @@ int kill_main(int argc, char **argv)
if (argc == 1) {
/* Print the whole signal list */
for (signo = 1; signo < 32; signo++) {
- puts(get_signame(signo));
+ const char *name = get_signame(signo);
+ if (!isdigit(name[0]))
+ puts(name);
}
} else { /* -l <sig list> */
while ((arg = *++argv)) {
diff --git a/procps/ps.c b/procps/ps.c
index 5128c3d..5545313 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -47,18 +47,21 @@ static void func_pgid(char *buf, int size, const procps_status_t *ps)
sprintf(buf, "%*u", size, ps->pgid);
}
-static void func_vsz(char *buf, int size, const procps_status_t *ps)
+static void put_u(char *buf, int size, unsigned u)
{
char buf5[5];
- smart_ulltoa5( ((unsigned long long)ps->vsz) << 10, buf5);
+ smart_ulltoa5( ((unsigned long long)u) << 10, buf5);
sprintf(buf, "%.*s", size, buf5);
}
+static void func_vsz(char *buf, int size, const procps_status_t *ps)
+{
+ put_u(buf, size, ps->vsz);
+}
+
static void func_rss(char *buf, int size, const procps_status_t *ps)
{
- char buf5[5];
- smart_ulltoa5( ((unsigned long long)ps->rss) << 10, buf5);
- sprintf(buf, "%.*s", size, buf5);
+ put_u(buf, size, ps->rss);
}
static void func_tty(char *buf, int size, const procps_status_t *ps)
@@ -383,7 +386,7 @@ int ps_main(int argc, char **argv)
len = printf("%5u %-8s %s ",
p->pid, user, p->state);
else
- len = printf("%5u %-8s %6ld %s ",
+ len = printf("%5u %-8s %6u %s ",
p->pid, user, p->vsz, p->state);
}