From 922f6f51dba8ba710cac0679635ed811b2139a53 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 1 Jul 2010 16:42:27 +0200 Subject: 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 --- miscutils/chrt.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'miscutils/chrt.c') diff --git a/miscutils/chrt.c b/miscutils/chrt.c index e2b7f8a..3d0da58 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 #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) -- cgit v1.1