aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 16:42:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-01 16:42:27 +0200
commit922f6f51dba8ba710cac0679635ed811b2139a53 (patch)
tree579ec114ed4608c99634b03bbcabfd94afd6e1bd /miscutils
parentcd0f6b0c939e5098410ddb171db8c4a26cf8d623 (diff)
downloadbusybox-922f6f51dba8ba710cac0679635ed811b2139a53.tar.gz
chrt: code shrink
function old new delta show_min_max 80 60 -20 packed_usage 26929 26896 -33 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-53) Total: -53 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/chrt.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/miscutils/chrt.c b/miscutils/chrt.c
index e2b7f8ae0..3d0da58ca 100644
--- a/miscutils/chrt.c
+++ b/miscutils/chrt.c
@@ -5,33 +5,35 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-
#include <sched.h>
#include "libbb.h"
#ifndef _POSIX_PRIORITY_SCHEDULING
#warning your system may be foobared
#endif
+
static const struct {
int policy;
- char name[12];
+ char name[sizeof("SCHED_OTHER")];
} policies[] = {
{SCHED_OTHER, "SCHED_OTHER"},
{SCHED_FIFO, "SCHED_FIFO"},
{SCHED_RR, "SCHED_RR"}
};
+//TODO: add
+// -b, SCHED_BATCH
+// -i, SCHED_IDLE
+
static void show_min_max(int pol)
{
- const char *fmt = "%s min/max priority\t: %d/%d\n\0%s not supported?\n";
+ const char *fmt = "%s min/max priority\t: %u/%u\n";
int max, min;
+
max = sched_get_priority_max(pol);
min = sched_get_priority_min(pol);
- if (max >= 0 && min >= 0)
- printf(fmt, policies[pol].name, min, max);
- else {
- fmt += 29;
- printf(fmt, policies[pol].name);
- }
+ if ((max|min) < 0)
+ fmt = "%s not supported\n";
+ printf(fmt, policies[pol].name, min, max);
}
#define OPT_m (1<<0)