summaryrefslogtreecommitdiff
path: root/src/shared/cgroup-show.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-16 05:04:53 +0200
committerLennart Poettering <lennart@poettering.net>2013-04-16 05:04:53 +0200
commit82da66fb750c91f06e713ff23a5e5c57ff05c2a8 (patch)
treed36730ca6eaca931106b96a90bced84651ce0bf5 /src/shared/cgroup-show.c
parentd8d3d8a781031d6b1ee4e5f57ec21f16c20a4cf2 (diff)
util: replace decimal_str_max() by a typesafe macro DECIMAL_STR_WIDTH()
DECIMAL_STR_WIDTH() now works on any numeric type, and is easier to distingish from DECIMAL_STR_MAX(). This also replaces another manual implementaiton of ulog10 by this macro.
Diffstat (limited to 'src/shared/cgroup-show.c')
-rw-r--r--src/shared/cgroup-show.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
index 9ee532ca22..0e82375ea9 100644
--- a/src/shared/cgroup-show.c
+++ b/src/shared/cgroup-show.c
@@ -40,17 +40,6 @@ static int compare(const void *a, const void *b) {
return 0;
}
-static unsigned ilog10(unsigned long ul) {
- int n = 0;
-
- while (ul > 0) {
- n++;
- ul /= 10;
- }
-
- return n;
-}
-
static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsigned n_columns, bool extra, bool more, bool kernel_threads, OutputFlags flags) {
unsigned i, m, pid_width;
pid_t biggest = 0;
@@ -71,7 +60,7 @@ static void show_pid_array(int pids[], unsigned n_pids, const char *prefix, unsi
pids[m++] = pids[i];
}
n_pids = m;
- pid_width = ilog10(biggest);
+ pid_width = DECIMAL_STR_WIDTH(biggest);
/* And sort */
qsort(pids, n_pids, sizeof(pid_t), compare);