From f29d074c6d17cddbc80bf5da924e8bbb43cfe507 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 23 Mar 2014 12:27:16 +0000 Subject: ps: exclude more unused code --- include/libbb.h | 4 ++++ libbb/procps.c | 4 ++-- procps/ps.c | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 1cc2a48b9..3b2bf0a0a 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -1633,7 +1633,11 @@ void free_procps_scan(procps_status_t* sp) FAST_FUNC; procps_status_t* procps_scan(procps_status_t* sp, int flags) FAST_FUNC; /* Format cmdline (up to col chars) into char buf[size] */ /* Puts [comm] if cmdline is empty (-> process is a kernel thread) */ +#if !ENABLE_PLATFORM_MINGW32 void read_cmdline(char *buf, int size, unsigned pid, const char *comm) FAST_FUNC; +#else +#define read_cmdline(buf, size, pid, comm) snprintf(buf, size, "[%s]", comm) +#endif pid_t *find_pid_by_name(const char* procName) FAST_FUNC; pid_t *pidlist_reverse(pid_t *pidList) FAST_FUNC; int starts_with_cpu(const char *str) FAST_FUNC; diff --git a/libbb/procps.c b/libbb/procps.c index e2f54d730..3c99ac6e7 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -570,8 +570,6 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) return sp; } -#endif /* ENABLE_PLATFORM_MINGW32 */ - void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm) { int sz; @@ -623,6 +621,8 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm) } } +#endif /* ENABLE_PLATFORM_MINGW32 */ + /* from kernel: // pid comm S ppid pgid sid tty_nr tty_pgrp flg sprintf(buffer,"%d (%s) %c %d %d %d %d %d %lu %lu \ diff --git a/procps/ps.c b/procps/ps.c index 32563776d..9fca3524e 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -240,6 +240,7 @@ static unsigned get_kernel_HZ(void) /* Print value to buf, max size+1 chars (including trailing '\0') */ +#if !ENABLE_PLATFORM_MINGW32 static void func_user(char *buf, int size, const procps_status_t *ps) { #if 1 @@ -263,12 +264,14 @@ static void func_group(char *buf, int size, const procps_status_t *ps) { safe_strncpy(buf, get_cached_groupname(ps->gid), size+1); } +#endif static void func_comm(char *buf, int size, const procps_status_t *ps) { safe_strncpy(buf, ps->comm, size+1); } +#if !ENABLE_PLATFORM_MINGW32 static void func_state(char *buf, int size, const procps_status_t *ps) { safe_strncpy(buf, ps->state, size+1); @@ -278,12 +281,14 @@ static void func_args(char *buf, int size, const procps_status_t *ps) { read_cmdline(buf, size+1, ps->pid, ps->comm); } +#endif static void func_pid(char *buf, int size, const procps_status_t *ps) { sprintf(buf, "%*u", size, ps->pid); } +#if !ENABLE_PLATFORM_MINGW32 static void func_ppid(char *buf, int size, const procps_status_t *ps) { sprintf(buf, "%*u", size, ps->ppid); @@ -320,6 +325,7 @@ static void func_tty(char *buf, int size, const procps_status_t *ps) if (ps->tty_major) /* tty field of "0" means "no tty" */ snprintf(buf, size+1, "%u,%u", ps->tty_major, ps->tty_minor); } +#endif #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS -- cgit v1.2.3-55-g6feb