summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2007-09-08 17:21:01 +0000
committerDenis Vlasenko2007-09-08 17:21:01 +0000
commite7c1ad1540ad18b17bd9ec93823dbf38583b5b87 (patch)
tree3eaab1a0a185b96652d0483639ff1e5ca36e9d91
parentff6e8e2974433aeabaaefaf9d8b6a35e9641b9ac (diff)
downloadbusybox-e7c1ad1540ad18b17bd9ec93823dbf38583b5b87.zip
busybox-e7c1ad1540ad18b17bd9ec93823dbf38583b5b87.tar.gz
top: add sizeof(G) check; fix style
-rw-r--r--procps/top.c48
1 files changed, 17 insertions, 31 deletions
diff --git a/procps/top.c b/procps/top.c
index 69f63d0..a958096 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -85,6 +85,12 @@ struct globals {
#endif
};
#define G (*(struct globals*)&bb_common_bufsiz1)
+#define INIT_G() \
+ do { \
+ struct G_sizecheck { \
+ char G_sizecheck[sizeof(G) > COMMON_BUFSIZE ? -1 : 1]; \
+ }; \
+ } while (0)
#define top (G.top )
#define ntop (G.ntop )
#define sort_field (G.sort_field )
@@ -512,20 +518,9 @@ static void sig_catcher(int sig ATTRIBUTE_UNUSED)
}
#endif /* FEATURE_USE_TERMIOS */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+/*
+ * TOPMEM support
+ */
typedef unsigned long mem_t;
@@ -766,20 +761,9 @@ void display_topmem_process_list(int count, int scr_width);
int topmem_sort(char *a, char *b);
#endif /* TOPMEM */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+/*
+ * end TOPMEM support
+ */
enum {
TOP_MASK = 0
@@ -802,7 +786,7 @@ int top_main(int argc, char **argv)
{
int count, lines, col;
unsigned interval;
- int iterations = 0; /* infinite */
+ int iterations;
char *sinterval, *siterations;
SKIP_FEATURE_TOPMEM(const) unsigned scan_mask = TOP_MASK;
#if ENABLE_FEATURE_USE_TERMIOS
@@ -814,7 +798,10 @@ int top_main(int argc, char **argv)
pfd[0].events = POLLIN;
#endif /* FEATURE_USE_TERMIOS */
+ INIT_G();
+
interval = 5; /* default update rate is 5 seconds */
+ iterations = 0; /* infinite */
/* do normal option parsing */
opt_complementary = "-";
@@ -852,8 +839,7 @@ int top_main(int argc, char **argv)
while (1) {
procps_status_t *p = NULL;
- /* Default */
- lines = 24;
+ lines = 24; /* default */
col = 79;
#if ENABLE_FEATURE_USE_TERMIOS
get_terminal_width_height(0, &col, &lines);