Module Name:    src
Committed By:   christos
Date:           Tue May  5 18:51:22 UTC 2009

Modified Files:
        src/external/bsd/top/dist: color.c color.h commands.c display.c
            display.h hash.c machine.h message.h screen.c screen.h sigconv.awk
            top.c username.c username.h utils.c utils.h version.c version.h
        src/external/bsd/top/dist/machine: m_netbsd.c

Log Message:
WARNS=4


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/top/dist/color.c \
    src/external/bsd/top/dist/display.h src/external/bsd/top/dist/hash.c \
    src/external/bsd/top/dist/screen.c src/external/bsd/top/dist/username.c \
    src/external/bsd/top/dist/utils.h
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/top/dist/color.h \
    src/external/bsd/top/dist/message.h src/external/bsd/top/dist/screen.h \
    src/external/bsd/top/dist/sigconv.awk \
    src/external/bsd/top/dist/username.h src/external/bsd/top/dist/version.c \
    src/external/bsd/top/dist/version.h
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/top/dist/commands.c \
    src/external/bsd/top/dist/display.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/top/dist/machine.h \
    src/external/bsd/top/dist/utils.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/top/dist/top.c
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/top/dist/machine/m_netbsd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/top/dist/color.c
diff -u src/external/bsd/top/dist/color.c:1.2 src/external/bsd/top/dist/color.c:1.3
--- src/external/bsd/top/dist/color.c:1.2	Fri Dec 12 18:09:08 2008
+++ src/external/bsd/top/dist/color.c	Tue May  5 14:51:21 2009
@@ -85,7 +85,7 @@
 static int max_color_ansi = 0;
 
 static int
-color_slot(char *str)
+color_slot(const char *str)
 
 {
     int i;
@@ -181,7 +181,7 @@
  */
 
 int
-color_tag(char *tag)
+color_tag(const char *tag)
 
 {
     color_entry *entryp;
@@ -334,9 +334,9 @@
     }
 }
 
+#ifdef notdef
 void
 color_debug(FILE *f)
-
 {
     color_entry *ep;
     int i;
@@ -359,6 +359,7 @@
     }
     fprintf(f, "\n");
 }
+#endif
 
 int
 color_activate(int i)
Index: src/external/bsd/top/dist/display.h
diff -u src/external/bsd/top/dist/display.h:1.2 src/external/bsd/top/dist/display.h:1.3
--- src/external/bsd/top/dist/display.h:1.2	Tue Jul 15 20:36:15 2008
+++ src/external/bsd/top/dist/display.h	Tue May  5 14:51:21 2009
@@ -37,11 +37,11 @@
 
 #include "globalstate.h"
 
-void display_clear();
-int display_resize();
-int display_lines();
+void display_clear(void);
+int display_resize(void);
+int display_lines(void);
 int display_setmulti(int m);
-int display_columns();
+int display_columns(void);
 int display_init(struct statics *statics, int percpuinfo);
 void i_loadave(int mpid, double *avenrun);
 void u_loadave(int mpid, double *avenrun);
@@ -54,7 +54,7 @@
 void u_procstates(int total, int *brkdn, int threads);
 void i_cpustates(int *states);
 void u_cpustates(int *states);
-void z_cpustates();
+void z_cpustates(void);
 void i_kernel(int *stats);
 void u_kernel(int *stats);
 void i_memory(long *stats);
@@ -67,19 +67,19 @@
 void u_header(char *text);
 void i_process(int line, char *thisline);
 void u_process(int, char *);
-void i_endscreen();
-void u_endscreen();
+void i_endscreen(void);
+void u_endscreen(void);
 void display_header(int t);
-void new_message(char *msgfmt, ...);
-void message_error(char *msgfmt, ...);
-void message_mark();
-void message_clear();
-void message_expire();
-void message_prompt(char *msgfmt, ...);
-void message_prompt_plain(char *msgfmt, ...);
+void new_message(const char *msgfmt, ...);
+void message_error(const char *msgfmt, ...);
+void message_mark(void);
+void message_clear(void);
+void message_expire(void);
+void message_prompt(const char *msgfmt, ...);
+void message_prompt_plain(const char *msgfmt, ...);
 int readline(char *buffer, int size, int numeric);
-void display_pagerstart();
-void display_pagerend();
-void display_pager(char *fmt, ...);
+void display_pagerstart(void);
+void display_pagerend(void);
+void display_pager(const char *fmt, ...);
 
 #endif
Index: src/external/bsd/top/dist/hash.c
diff -u src/external/bsd/top/dist/hash.c:1.2 src/external/bsd/top/dist/hash.c:1.3
--- src/external/bsd/top/dist/hash.c:1.2	Fri Dec 12 18:09:08 2008
+++ src/external/bsd/top/dist/hash.c	Tue May  5 14:51:21 2009
@@ -104,14 +104,14 @@
     return (s % ht->num_buckets);
 }
 
-void ll_init(llist *q)
+static void ll_init(llist *q)
 
 {
     q->head = NULL;
     q->count = 0;
 }
 
-llistitem *ll_newitem(int size)
+static llistitem *ll_newitem(int size)
 
 {
     llistitem *qi;
@@ -121,13 +121,13 @@
     return qi;
 }
 
-void ll_freeitem(llistitem *li)
+static void ll_freeitem(llistitem *li)
 
 {
     free(li);
 }
 
-void ll_add(llist *q, llistitem *new)
+static void ll_add(llist *q, llistitem *new)
 
 {
     new->next = q->head;
@@ -135,7 +135,7 @@
     q->count++;
 }
 
-void ll_extract(llist *q, llistitem *qi, llistitem *last)
+static void ll_extract(llist *q, llistitem *qi, llistitem *last)
 
 {
     if (last == NULL)
@@ -151,28 +151,31 @@
 }
 
 #define LL_FIRST(q) ((q)->head)
-llistitem *
+#define LL_NEXT(q, qi)  ((qi) != NULL ? (qi)->next : NULL)
+#define LL_ISEMPTY(ll)  ((ll)->count == 0)
+
+#ifdef notdef
+static llistitem *
 ll_first(llist *q)
 
 {
     return q->head;
 }
 
-#define LL_NEXT(q, qi)  ((qi) != NULL ? (qi)->next : NULL)
-llistitem *
+static llistitem *
 ll_next(llist *q, llistitem *qi)
 
 {
     return (qi != NULL ? qi->next : NULL);
 }
 
-#define LL_ISEMPTY(ll)  ((ll)->count == 0)
-int
+static int
 ll_isempty(llist *ll)
 
 {
     return (ll->count == 0);
 }
+#endif
 
 /*
  * hash_table *hash_create(int num)
@@ -217,7 +220,8 @@
  * Return total number of elements contained in hash table.
  */
 
-unsigned int
+#ifdef notdef
+static unsigned int
 hash_count(hash_table *ht)
 
 {
@@ -234,6 +238,7 @@
 
     return cnt;
 }
+#endif
 
 /*
  * void hash_sizeinfo(unsigned int *sizes, int max, hash_table *ht)
Index: src/external/bsd/top/dist/screen.c
diff -u src/external/bsd/top/dist/screen.c:1.2 src/external/bsd/top/dist/screen.c:1.3
--- src/external/bsd/top/dist/screen.c:1.2	Thu Aug 28 20:36:27 2008
+++ src/external/bsd/top/dist/screen.c	Tue May  5 14:51:21 2009
@@ -214,7 +214,6 @@
     char *bufptr;
     char *PCptr;
     char *term_name;
-    char *getenv();
     int status;
 
     /* set defaults in case we aren't smart */
@@ -507,7 +506,7 @@
 }
 
 void
-screen_standout(char *msg)
+screen_standout(const char *msg)
 
 {
     if (smart_terminal)
@@ -523,7 +522,7 @@
 }
 
 void
-screen_clear()
+screen_clear(void)
 
 {
     if (smart_terminal)
@@ -533,7 +532,7 @@
 }
 
 int
-screen_cte()
+screen_cte(void)
 
 {
     if (smart_terminal)
@@ -579,7 +578,7 @@
 }
 
 void
-screen_home()
+screen_home(void)
 
 {
     if (smart_terminal)
Index: src/external/bsd/top/dist/username.c
diff -u src/external/bsd/top/dist/username.c:1.2 src/external/bsd/top/dist/username.c:1.3
--- src/external/bsd/top/dist/username.c:1.2	Fri Dec 12 18:09:08 2008
+++ src/external/bsd/top/dist/username.c	Tue May  5 14:51:22 2009
@@ -52,6 +52,7 @@
 #include "top.h"
 #include "utils.h"
 #include "hash.h"
+#include "username.h"
 
 #define EXPIRETIME (60 * 5)
 
@@ -74,14 +75,14 @@
 
 
 void
-init_username()
+init_username(void)
 
 {
     userhash = hash_create(211);
 }
 
 char *
-username(int uid)
+username(int xuid)
 
 {
     struct hash_data *data;
@@ -92,7 +93,7 @@
     now = time(NULL);
 
     /* get whatever is in the cache */
-    data = hash_lookup_uint(userhash, (unsigned int)uid);
+    data = hash_lookup_uint(userhash, (unsigned int)xuid);
 
     /* if we had a cache miss, then create space for a new entry */
     if (data == NULL)
@@ -101,18 +102,18 @@
 	data = emalloc(sizeof(struct hash_data));
 
 	/* fill in some data, including an already expired time */
-	data->uid = uid;
+	data->uid = xuid;
 	data->expire = (time_t)0;
 
 	/* add it to the hash: the rest gets filled in later */
-	hash_add_uint(userhash, uid, data);
+	hash_add_uint(userhash, xuid, data);
     }
 
-    /* Now data points to the correct hash entry for "uid".  If this is
+    /* Now data points to the correct hash entry for "xuid".  If this is
        a new entry, then expire is 0 and the next test will be true. */
     if (data->expire <= now)
     {
-	if ((pw = getpwuid(uid)) != NULL)
+	if ((pw = getpwuid(xuid)) != NULL)
 	{
 	    strncpy(data->name, pw->pw_name, MAXLOGNAME-1);
 	    data->expire = now + EXPIRETIME;
@@ -122,7 +123,7 @@
 	else
 	{
 	    /* username doesnt exist ... so invent one */
-	    snprintf(data->name, sizeof(data->name), "%d", uid);
+	    snprintf(data->name, sizeof(data->name), "%d", xuid);
 	    data->expire = now + EXPIRETIME;
 	    dprintf("username: updating %d with %s, expires %d\n",
 		    data->uid, data->name, data->expire);
@@ -134,12 +135,12 @@
 }
 
 int
-userid(char *username)
+userid(char *xusername)
 
 {
     struct passwd *pwd;
 
-    if ((pwd = getpwnam(username)) == NULL)
+    if ((pwd = getpwnam(xusername)) == NULL)
     {
 	return(-1);
     }
Index: src/external/bsd/top/dist/utils.h
diff -u src/external/bsd/top/dist/utils.h:1.2 src/external/bsd/top/dist/utils.h:1.3
--- src/external/bsd/top/dist/utils.h:1.2	Wed Jul 16 10:27:26 2008
+++ src/external/bsd/top/dist/utils.h	Tue May  5 14:51:22 2009
@@ -45,20 +45,20 @@
 char *itoa7(int);
 int digits(int);
 char *printable(char *);
-char *strcpyend(char *, char *);
-char *homogenize(char *);
-int string_index(char *, char **);
+char *strcpyend(char *, const char *);
+char *homogenize(const char *);
+int string_index(const char *, const char **);
 char **argparse(char *, int *);
 long percentages(int, int *, long *, long *, long *);
-char *errmsg(int);
+const char *errmsg(int);
 char *format_percent(double);
 char *format_time(long);
 char *format_k(long);
-char *string_list(char **);
+char *string_list(const char **);
 void time_get(struct timeval *);
 void time_mark(struct timeval *);
 void double2tv(struct timeval *, double);
-unsigned int time_elapsed();
+unsigned int time_elapsed(void);
 unsigned int diff_per_second(unsigned int, unsigned int);
 void debug_set(int);
 #ifdef DEBUG

Index: src/external/bsd/top/dist/color.h
diff -u src/external/bsd/top/dist/color.h:1.1.1.1 src/external/bsd/top/dist/color.h:1.2
--- src/external/bsd/top/dist/color.h:1.1.1.1	Tue Jul 15 20:20:32 2008
+++ src/external/bsd/top/dist/color.h	Tue May  5 14:51:21 2009
@@ -42,7 +42,7 @@
 #define COLOR_ANSI_SLOTS 20
 
 int color_env_parse(char *env);
-int color_tag(char *tag);
+int color_tag(const char *tag);
 int color_test(int tagidx, int value);
 char *color_setstr(int color);
 void color_dump(FILE *f);
Index: src/external/bsd/top/dist/message.h
diff -u src/external/bsd/top/dist/message.h:1.1.1.1 src/external/bsd/top/dist/message.h:1.2
--- src/external/bsd/top/dist/message.h:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/message.h	Tue May  5 14:51:21 2009
@@ -38,7 +38,7 @@
 #ifndef _MESSAGE_H
 #define _MESSAGE_H
 
-void error_message(char *msgfmt, ...);
-void clear_message();
+void error_message(const char *msgfmt, ...);
+void clear_message(void);
 
 #endif /* _MESSAGE_H_ */
Index: src/external/bsd/top/dist/screen.h
diff -u src/external/bsd/top/dist/screen.h:1.1.1.1 src/external/bsd/top/dist/screen.h:1.2
--- src/external/bsd/top/dist/screen.h:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/screen.h	Tue May  5 14:51:21 2009
@@ -50,16 +50,16 @@
 extern int  screen_length;
 extern int  screen_width;
 
-void screen_getsize();
+void screen_getsize(void);
 int screen_readtermcap(int interactive);
-void screen_init();
-void screen_end();
-void screen_reinit();
+void screen_init(void);
+void screen_end(void);
+void screen_reinit(void);
 void screen_move(int x, int y);
-void screen_standout(char *msg);
-void screen_clear();
-int screen_cte();
+void screen_standout(const char *msg);
+void screen_clear(void);
+int screen_cte(void);
 void screen_cleareol(int len);
-void screen_home();
+void screen_home(void);
 
 #endif /* _SCREEN_H_ */
Index: src/external/bsd/top/dist/sigconv.awk
diff -u src/external/bsd/top/dist/sigconv.awk:1.1.1.1 src/external/bsd/top/dist/sigconv.awk:1.2
--- src/external/bsd/top/dist/sigconv.awk:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/sigconv.awk	Tue May  5 14:51:21 2009
@@ -39,7 +39,7 @@
 		    print "/* This file was automatically generated */"
 		    print "/* by the awk script \"sigconv.awk\".      */\n"
 		    print "struct sigdesc {"
-		    print "    char *name;"
+		    print "    const char *name;"
 		    print "    int  number;"
 		    print "};\n"
 		    print "struct sigdesc sigdesc[] = {"
Index: src/external/bsd/top/dist/username.h
diff -u src/external/bsd/top/dist/username.h:1.1.1.1 src/external/bsd/top/dist/username.h:1.2
--- src/external/bsd/top/dist/username.h:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/username.h	Tue May  5 14:51:22 2009
@@ -35,7 +35,7 @@
 #ifndef _USERNAME_H_
 #define _USERNAME_H_
 
-void init_username();
+void init_username(void);
 char *username(int uid);
 int userid(char *username);
 
Index: src/external/bsd/top/dist/version.c
diff -u src/external/bsd/top/dist/version.c:1.1.1.1 src/external/bsd/top/dist/version.c:1.2
--- src/external/bsd/top/dist/version.c:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/version.c	Tue May  5 14:51:22 2009
@@ -37,9 +37,10 @@
 
 #include "config.h"
 #include "top.h"
+#include "version.h"
 
-char *
-version_string()
+const char *
+version_string(void)
 
 {
     return(PACKAGE_VERSION);
Index: src/external/bsd/top/dist/version.h
diff -u src/external/bsd/top/dist/version.h:1.1.1.1 src/external/bsd/top/dist/version.h:1.2
--- src/external/bsd/top/dist/version.h:1.1.1.1	Tue Jul 15 20:20:33 2008
+++ src/external/bsd/top/dist/version.h	Tue May  5 14:51:22 2009
@@ -34,4 +34,4 @@
  *  Top users/processes display for Unix
  */
 
-char *version_string();
+const char *version_string(void);

Index: src/external/bsd/top/dist/commands.c
diff -u src/external/bsd/top/dist/commands.c:1.5 src/external/bsd/top/dist/commands.c:1.6
--- src/external/bsd/top/dist/commands.c:1.5	Fri Dec 12 18:09:08 2008
+++ src/external/bsd/top/dist/commands.c	Tue May  5 14:51:21 2009
@@ -75,14 +75,12 @@
 #include "utils.h"
 #include "version.h"
 
-extern int  errno;
-
 extern char *copyright;
 
 typedef struct command {
     int ch;
     int (*cmd_func)(globalstate *);
-    char *help;
+    const char *help;
 } command;
 
 /*
@@ -117,17 +115,17 @@
  *	for sorting errors.
  */
 
-int
+static int
 err_compar(const void *p1, const void *p2)
 
 {
     register int result;
 
-    if ((result = ((struct errs *)p1)->errnum -
-	 ((struct errs *)p2)->errnum) == 0)
+    if ((result = ((const struct errs *)p1)->errnum -
+	 ((const struct errs *)p2)->errnum) == 0)
     {
-	return(strcmp(((struct errs *)p1)->arg,
-		      ((struct errs *)p2)->arg));
+	return(strcmp(((const struct errs *)p1)->arg,
+		      ((const struct errs *)p2)->arg));
     }
     return(result);
 }
@@ -138,11 +136,11 @@
  *      number of characters remaining in str, or 0 if overflowed.
  */
 
-int
+static int
 str_adderr(char *str, int len, int err)
 
 {
-    register char *msg;
+    register const char *msg;
     register int  msglen;
 
     msg = err == 0 ? "Not a number" : errmsg(err);
@@ -164,7 +162,7 @@
  *      remaining in str, or 0 if overflowed.
  */
 
-int
+static int
 str_addarg(char *str, int len, char *arg, int first)
 
 {
@@ -198,8 +196,8 @@
 
 #define STRMAX 80
 
-void
-err_string()
+static void
+err_string(void)
 
 {
     register struct errs *errp;
@@ -266,7 +264,7 @@
  *  Utility routines that help with some of the commands.
  */
 
-char *
+static char *
 next_field(char *str)
 
 
@@ -283,7 +281,7 @@
     return(*str == '\0' ? NULL : str);
 }
 
-int
+static int
 scanint(char *str, int *intp)
 
 {
@@ -316,12 +314,13 @@
     return(0);
 }
 
+#ifdef notdef
 /*
  *  error_count() - return the number of errors currently logged.
  */
 
-int
-error_count()
+static int
+error_count(void)
 
 {
     return(errcnt);
@@ -331,8 +330,8 @@
  *  show_errors() - display on stdout the current log of errors.
  */
 
-void
-show_errors()
+static void
+show_errors(void)
 
 {
     register int cnt = 0;
@@ -346,13 +345,14 @@
 	errp++;
     }
 }
+#endif
 
 /*
  *  kill_procs(str) - send signals to processes, much like the "kill"
  *		command does; invoked in response to 'k'.
  */
 
-void
+static void
 kill_procs(char *str)
 
 {
@@ -468,7 +468,7 @@
  *		"renice" command does; invoked in response to 'r'.
  */
 
-void
+static void
 renice_procs(char *str)
 
 {
@@ -547,7 +547,7 @@
  * returns will be returned by command_process.
  */
 
-void
+static void
 cmd_quit(globalstate *gstate)
 
 {
@@ -555,7 +555,7 @@
     /*NOTREACHED*/
 }
 
-int
+static int
 cmd_update(globalstate *gstate)
 
 {
@@ -566,7 +566,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_redraw(globalstate *gstate)
 
 {
@@ -574,7 +574,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_color(globalstate *gstate)
 
 {
@@ -583,7 +583,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_number(globalstate *gstate)
 
 {
@@ -616,7 +616,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_delay(globalstate *gstate)
 
 {
@@ -639,7 +639,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_idle(globalstate *gstate)
 
 {
@@ -649,7 +649,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_displays(globalstate *gstate)
 
 {
@@ -672,7 +672,7 @@
     return CMD_OK;
 }
 
-int
+static int
 cmd_cmdline(globalstate *gstate)
 
 {
@@ -687,7 +687,7 @@
     return CMD_OK;
 }
 
-int
+static int
 cmd_order(globalstate *gstate)
 
 {
@@ -713,13 +713,13 @@
     return CMD_OK;
 }
 
-int
-cmd_order_x(globalstate *gstate, char *name, ...)
+static int
+cmd_order_x(globalstate *gstate, const char *name, ...)
 
 {
     va_list ap;
     char *p;
-    char **names;
+    const char **names;
     int i;
 
     names = gstate->statics->order_names;
@@ -750,28 +750,28 @@
     return CMD_OK;
 }
 
-int
+static int
 cmd_order_cpu(globalstate *gstate)
 
 {
     return cmd_order_x(gstate, "cpu", NULL);
 }
 
-int
+static int
 cmd_order_pid(globalstate *gstate)
 
 {
     return cmd_order_x(gstate, "pid", NULL);
 }
 
-int
+static int
 cmd_order_mem(globalstate *gstate)
 
 {
     return cmd_order_x(gstate, "mem", "size", NULL);
 }
 
-int
+static int
 cmd_order_time(globalstate *gstate)
 
 {
@@ -780,7 +780,7 @@
 
 #ifdef ENABLE_KILL
 
-int
+static int
 cmd_kill(globalstate *gstate)
 
 {
@@ -794,7 +794,7 @@
     return CMD_OK;
 }
 	    
-int
+static int
 cmd_renice(globalstate *gstate)
 
 {
@@ -810,7 +810,7 @@
 
 #endif
 
-int
+static int
 cmd_pid(globalstate *gstate)
 
 {
@@ -827,7 +827,7 @@
     return CMD_OK;
 }
 
-int
+static int
 cmd_user(globalstate *gstate)
 
 {
@@ -857,7 +857,7 @@
     return ret;
 }
 
-int
+static int
 cmd_command(globalstate *gstate)
 
 {
@@ -880,7 +880,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_useruid(globalstate *gstate)
 
 {
@@ -889,7 +889,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_mode(globalstate *gstate)
 
 {
@@ -902,7 +902,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_system(globalstate *gstate)
 
 {
@@ -911,7 +911,7 @@
     return CMD_REFRESH;
 }
 
-int
+static int
 cmd_threads(globalstate *gstate)
 
 {
@@ -924,7 +924,7 @@
     return CMD_NA;
 }
 
-int
+static int
 cmd_percpustates(globalstate *gstate)
 {
 	gstate->percpustates = !gstate->percpustates;
@@ -982,7 +982,7 @@
     command *c;
     char buf[12];
     char *p;
-    char *help;
+    const char *help;
 
     display_pagerstart();
 
Index: src/external/bsd/top/dist/display.c
diff -u src/external/bsd/top/dist/display.c:1.5 src/external/bsd/top/dist/display.c:1.6
--- src/external/bsd/top/dist/display.c:1.5	Fri Feb 27 12:38:14 2009
+++ src/external/bsd/top/dist/display.c	Tue May  5 14:51:21 2009
@@ -131,11 +131,11 @@
 /* virtual cursor */
 static int virt_x, virt_y;
 
-static char **procstate_names;
-static char **cpustate_names;
-static char **memory_names;
-static char **swap_names;
-static char **kernel_names;
+static const char **procstate_names;
+static const char **cpustate_names;
+static const char **memory_names;
+static const char **swap_names;
+static const char **kernel_names;
 
 static int num_procstates;
 static int num_cpustates;
@@ -193,7 +193,7 @@
  */
 
 static int
-string_count(char **pp)
+string_count(const char **pp)
 
 {
     register int cnt = 0;
@@ -209,7 +209,7 @@
 }
 
 void
-display_clear()
+display_clear(void)
 
 {
     dprintf("display_clear\n");
@@ -228,7 +228,7 @@
  * already on the screen.
  */
 
-void
+static void
 display_move(int x, int y)
 
 {
@@ -325,8 +325,8 @@
  * escape sequences.
  */
 
-void
-display_write(int x, int y, int newcolor, int eol, char *new)
+static void
+display_write(int x, int y, int newcolor, int eol, const char *new)
 
 {
     char *bufp;
@@ -450,8 +450,8 @@
     }
 }
 
-void
-display_fmt(int x, int y, int newcolor, int eol, char *fmt, ...)
+static void
+display_fmt(int x, int y, int newcolor, int eol, const char *fmt, ...)
 
 {
     va_list argp;
@@ -462,8 +462,8 @@
     display_write(x, y, newcolor, eol, scratchbuf);
 }
 
-void
-display_cte()
+static void
+display_cte(void)
 
 {
     int len;
@@ -528,12 +528,12 @@
 }
 
 static void
-summary_format(int x, int y, int *numbers, char **names, int *cidx)
+summary_format(int x, int y, int *numbers, const char **names, int *cidx)
 
 {
     register int num;
-    register char *thisname;
-    register char *lastname = NULL;
+    register const char *thisname;
+    register const char *lastname = NULL;
     register int color;
 
     /* format each number followed by its string */
@@ -591,13 +591,13 @@
 }
 
 static void
-summary_format_memory(int x, int y, long *numbers, char **names, int *cidx)
+summary_format_memory(int x, int y, long *numbers, const char **names, int *cidx)
 
 {
     register long num;
     register int color;
-    register char *thisname;
-    register char *lastname = NULL;
+    register const char *thisname;
+    register const char *lastname = NULL;
 
     /* format each number followed by its string */
     while ((thisname = *names++) != NULL)
@@ -789,7 +789,7 @@
 
 {
     register int top_lines;
-    register char **pp;
+    register const char **pp;
     register char *p;
     register int *ip;
     register int i;
@@ -1143,16 +1143,16 @@
 
 /* cpustates_tag() calculates the correct tag to use to label the line */
 
-char *
+static char *
 cpustates_tag(int c)
 
 {
-    register char *use;
+    register const char *use;
 
     static char fmttag[100];
 
-    char *short_tag = ncpu > 1 && multi ? "CPU%d: " : "CPU: ";
-    char *long_tag = ncpu > 1 && multi ? "CPU%d states: " : "CPU states: ";
+    const char *short_tag = ncpu > 1 && multi ? "CPU%d: " : "CPU: ";
+    const char *long_tag = ncpu > 1 && multi ? "CPU%d states: " : "CPU states: ";
 
     /* if length + strlen(long_tag) >= screen_width, then we have to
        use the shorter tag (we subtract 2 to account for ": ") */
@@ -1178,8 +1178,8 @@
 
 {
     int value;
-    char **names;
-    char *thisname;
+    const char **names;
+    const char *thisname;
     int *colp;
     int color = 0;
 #ifdef ENABLE_COLOR
@@ -1243,8 +1243,8 @@
 
 {
     int value;
-    char **names;
-    char *thisname;
+    const char **names;
+    const char *thisname;
     int *lp;
     int *colp;
     int color = 0;
@@ -1313,8 +1313,8 @@
 
 {
     register int i, c;
-    register char **names = cpustate_names;
-    register char *thisname;
+    register const char **names = cpustate_names;
+    register const char *thisname;
     register int *lp;
 
     /* print tag */
@@ -1631,22 +1631,22 @@
 }
 
 void
-message_mark()
+message_mark(void)
 
 {
     message_barrier = Yes;
 }
 
 void
-message_expire()
+message_expire(void)
 
 {
     message_time.tv_sec = 0;
     message_time.tv_usec = 0;
 }
 
-void
-message_flush()
+static void
+message_flush(void)
 
 {
     message_first = message_last;
@@ -1665,8 +1665,8 @@
  */
 
 
-void
-new_message_v(char *msgfmt, va_list ap)
+static void
+new_message_v(const char *msgfmt, va_list ap)
 
 {
     int i;
@@ -1716,7 +1716,7 @@
  */
 
 void
-new_message(char *msgfmt, ...)
+new_message(const char *msgfmt, ...)
 
 {
     va_list ap;
@@ -1735,7 +1735,7 @@
  */
 
 void
-message_error(char *msgfmt, ...)
+message_error(const char *msgfmt, ...)
 
 {
     va_list ap;
@@ -1779,8 +1779,8 @@
  * prompt.  This call causes all pending messages to be flushed.
  */
 
-void
-message_prompt_v(int so, char *msgfmt, va_list ap)
+static void
+message_prompt_v(int so, const char *msgfmt, va_list ap)
 
 {
     char msg[MAX_COLS];
@@ -1822,7 +1822,7 @@
  */
 
 void
-message_prompt(char *msgfmt, ...)
+message_prompt(const char *msgfmt, ...)
 
 {
     va_list ap;
@@ -1833,7 +1833,7 @@
 }
 
 void
-message_prompt_plain(char *msgfmt, ...)
+message_prompt_plain(const char *msgfmt, ...)
 
 {
     va_list ap;
@@ -1971,7 +1971,7 @@
 }
 
 void
-display_pager(char *fmt, ...)
+display_pager(const char *fmt, ...)
 
 {
     va_list ap;

Index: src/external/bsd/top/dist/machine.h
diff -u src/external/bsd/top/dist/machine.h:1.3 src/external/bsd/top/dist/machine.h:1.4
--- src/external/bsd/top/dist/machine.h:1.3	Sun Jul 20 14:52:06 2008
+++ src/external/bsd/top/dist/machine.h	Tue May  5 14:51:21 2009
@@ -47,13 +47,13 @@
  */
 struct statics
 {
-    char **procstate_names;
-    char **cpustate_names;
-    char **memory_names;
-    char **swap_names;		/* optional */
-    char **order_names;		/* optional */
-    char **top_color_names;	/* optional */
-    char **kernel_names;	/* optional */
+    const char **procstate_names;
+    const char **cpustate_names;
+    const char **memory_names;
+    const char **swap_names;		/* optional */
+    const char **order_names;		/* optional */
+    const char **top_color_names;	/* optional */
+    const char **kernel_names;	/* optional */
     time_t boottime;		/* optional */
     int modemax;		/* optional */
     int ncpu;			/* optional */
@@ -77,7 +77,7 @@
 
 struct system_info
 {
-    int    last_pid;
+    pid_t    last_pid;
     double load_avg[NUM_AVERAGES];
     int    p_total;
     int    P_ACTIVE;     /* number of procs considered "active" */
@@ -107,7 +107,7 @@
     char *command;	/* only this command (unless == NULL) */
     int mode;		/* select display mode (0 is default) */
     int threads;	/* show threads separately */
-    int pid;		/* show only this pid (unless pid == -1) */
+    pid_t pid;		/* show only this pid (unless pid == -1) */
 };
 
 /* routines defined by the machine dependent module */
Index: src/external/bsd/top/dist/utils.c
diff -u src/external/bsd/top/dist/utils.c:1.3 src/external/bsd/top/dist/utils.c:1.4
--- src/external/bsd/top/dist/utils.c:1.3	Fri Dec 12 18:09:08 2008
+++ src/external/bsd/top/dist/utils.c	Tue May  5 14:51:22 2009
@@ -231,7 +231,7 @@
  */
 
 char *
-strcpyend(char *to, char *from)
+strcpyend(char *to, const char *from)
 
 {
     while ((*to++ = *from++) != '\0');
@@ -240,13 +240,13 @@
 
 /*
  * char *
- * homogenize(char *str)
+ * homogenize(const char *str)
  *
  * Remove unwanted characters from "str" and make everything lower case.
  * Newly allocated string is returned: the original is not altered.
  */
 
-char *homogenize(char *str)
+char *homogenize(const char *str)
 
 {
     char *ans;
@@ -272,7 +272,7 @@
  */
 
 int
-string_index(char *string, char **array)
+string_index(const char *string, const char **array)
 
 {
     register int i = 0;
@@ -297,12 +297,12 @@
  * caller is done.  Note that this is not an efficient function.
  */
 
-char *string_list(char **strings)
+char *string_list(const char **strings)
 
 {
     int cnt = 0;
-    char **pp;
-    char *p;
+    const char **pp;
+    const char *p;
     char *result = NULL;
     char *resp = NULL;
 
@@ -484,7 +484,7 @@
 extern int sys_nerr;
 #endif
 
-char *
+const char *
 errmsg(int errnum)
 
 {
@@ -611,12 +611,12 @@
 
 {
     static char retarray[NUM_STRINGS][16];
-    static int index = 0;
+    static int idx = 0;
     register char *ret;
     register char tag = 'K';
 
-    ret = retarray[index];
-    index = (index + 1) % NUM_STRINGS;
+    ret = retarray[idx];
+    idx = (idx + 1) % NUM_STRINGS;
 
     if (amt >= 10000)
     {
@@ -629,7 +629,7 @@
 	}
     }
 
-    snprintf(ret, sizeof(retarray[index])-1, "%ld%c", amt, tag);
+    snprintf(ret, sizeof(retarray[idx])-1, "%ld%c", amt, tag);
 
     return(ret);
 }

Index: src/external/bsd/top/dist/top.c
diff -u src/external/bsd/top/dist/top.c:1.7 src/external/bsd/top/dist/top.c:1.8
--- src/external/bsd/top/dist/top.c:1.7	Sat Dec 13 04:05:56 2008
+++ src/external/bsd/top/dist/top.c	Tue May  5 14:51:22 2009
@@ -30,7 +30,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-char *copyright =
+const char *copyright =
     "Copyright (c) 1984 through 2008, William LeFebvre";
 
 /*
@@ -112,7 +112,7 @@
 static jmp_buf jmp_int;
 
 /* globals */
-char *myname = "top";
+char *myname;
 
 void
 quit(int status)
@@ -128,7 +128,7 @@
  *  signal handlers
  */
 
-void
+static void
 set_signal(int sig, RETSIGTYPE (*handler)(int))
 
 {
@@ -143,7 +143,7 @@
 #endif
 }
 
-void
+static void
 release_signal(int sig)
 
 {
@@ -163,7 +163,7 @@
 #endif
 }
 
-RETSIGTYPE
+static RETSIGTYPE
 sig_leave(int i)	/* exit under normal conditions -- INT handler */
 
 {
@@ -171,7 +171,7 @@
     exit(EX_OK);
 }
 
-RETSIGTYPE
+static RETSIGTYPE
 sig_tstop(int i)	/* SIGTSTP handler */
 
 {
@@ -201,7 +201,7 @@
 }
 
 #ifdef SIGWINCH
-RETSIGTYPE
+static RETSIGTYPE
 sig_winch(int i)		/* SIGWINCH handler */
 
 {
@@ -217,8 +217,8 @@
 static sigset_t signalset;
 #endif
 
-void *
-hold_signals()
+static void *
+hold_signals(void)
 
 {
 #ifdef HAVE_SIGACTION
@@ -256,8 +256,8 @@
 
 }
 
-void
-set_signals()
+static void
+set_signals(void)
 
 {
     (void) set_signal(SIGINT, sig_leave);
@@ -268,7 +268,7 @@
 #endif
 }
 
-void
+static void
 release_signals(void *parm)
 
 {
@@ -325,7 +325,7 @@
 #endif
 
 
-void
+static void
 do_arguments(globalstate *gstate, int ac, char **av)
 
 {
@@ -489,7 +489,7 @@
     }
 }
 
-void
+static void
 do_display(globalstate *gstate)
 
 {
@@ -602,7 +602,7 @@
 }
 #endif
 
-void
+static void
 do_wait(globalstate *gstate)
 
 {
@@ -612,7 +612,7 @@
     select(0, NULL, NULL, NULL, &wait);
 }
 
-void
+static void
 do_command(globalstate *gstate)
 
 {
@@ -687,7 +687,7 @@
     } while (timercmp(&now, &(gstate->refresh), < ));
 }
 
-void
+static void
 do_minidisplay(globalstate *gstate)
 
 {
@@ -721,7 +721,8 @@
     char **preset_argv;
     int preset_argc = 0;
     void *mask;
-    int need_mini = 1;
+    volatile int need_mini = 1;
+    static char top[] = "top";
 
     struct statics statics;
     globalstate *gstate;
@@ -737,7 +738,9 @@
 	{
 	    myname++;
 	}
-    }
+    } else
+	myname = top;
+
 
     /* binary compatibility check */
 #ifdef HAVE_UNAME

Index: src/external/bsd/top/dist/machine/m_netbsd.c
diff -u src/external/bsd/top/dist/machine/m_netbsd.c:1.8 src/external/bsd/top/dist/machine/m_netbsd.c:1.9
--- src/external/bsd/top/dist/machine/m_netbsd.c:1.8	Fri Apr 24 15:07:45 2009
+++ src/external/bsd/top/dist/machine/m_netbsd.c	Tue May  5 14:51:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: m_netbsd.c,v 1.8 2009/04/24 19:07:45 njoly Exp $	*/
+/*	$NetBSD: m_netbsd.c,v 1.9 2009/05/05 18:51:22 christos Exp $	*/
 
 /*
  * top - a top users display for Unix
@@ -37,12 +37,12 @@
  *		Andrew Doran <[email protected]>
  *
  *
- * $Id: m_netbsd.c,v 1.8 2009/04/24 19:07:45 njoly Exp $
+ * $Id: m_netbsd.c,v 1.9 2009/05/05 18:51:22 christos Exp $
  */
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: m_netbsd.c,v 1.8 2009/04/24 19:07:45 njoly Exp $");
+__RCSID("$NetBSD: m_netbsd.c,v 1.9 2009/05/05 18:51:22 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -144,7 +144,7 @@
 /* these are for detailing the process states */
 
 int process_states[8];
-char *procstatenames[] = {
+const char *procstatenames[] = {
 	"", " idle, ", " runnable, ", " sleeping, ", " stopped, ",
 	" zombie, ", " dead, ", " on CPU, ",
 	NULL
@@ -153,28 +153,28 @@
 /* these are for detailing the CPU states */
 
 int *cpu_states;
-char *cpustatenames[] = {
+const char *cpustatenames[] = {
 	"user", "nice", "system", "interrupt", "idle", NULL
 };
 
 /* these are for detailing the memory statistics */
 
 long memory_stats[7];
-char *memorynames[] = {
+const char *memorynames[] = {
 	"K Act, ", "K Inact, ", "K Wired, ", "K Exec, ", "K File, ",
 	"K Free, ",
 	NULL
 };
 
 long swap_stats[4];
-char *swapnames[] = {
+const char *swapnames[] = {
 	"K Total, ", "K Used, ", "K Free, ",
 	NULL
 };
 
 
 /* these are names given to allowed sorting orders -- first is default */
-char *ordernames[] = {
+const char *ordernames[] = {
 	"cpu",
 	"pri",
 	"res",
@@ -414,8 +414,7 @@
 }
 
 void
-get_system_info(si)
-	struct system_info *si;
+get_system_info(struct system_info *si)
 {
 	size_t ssize;
 	int mib[2];
@@ -435,11 +434,11 @@
 	}
 
 	if (getloadavg(si->load_avg, NUM_AVERAGES) < 0) {
-		int i;
+		int j;
 
 		warn("can't getloadavg");
-		for (i = 0; i < NUM_AVERAGES; i++)
-			si->load_avg[i] = 0.0;
+		for (j = 0; j < NUM_AVERAGES; j++)
+			si->load_avg[j] = 0.0;
 	}
 
 	/* convert cp_time counts to percentages */
@@ -516,7 +515,7 @@
 	int i;
 
 	for (i = 0; i < thread_nproc; i++, pp++)
-		if (pp->p_pid == pl->l_pid)
+		if ((pid_t)pp->p_pid == (pid_t)pl->l_pid)
 			return pp;
 	return NULL;
 }
@@ -563,7 +562,7 @@
 
 	procgen++;
 
-	if (sel->pid == -1) {
+	if (sel->pid == (pid_t)-1) {
 		op = KERN_PROC_ALL;
 		arg = 0;
 	} else {
@@ -573,7 +572,7 @@
 
 	pbase = kvm_getproc2(kd, op, arg, sizeof(struct kinfo_proc2), &nproc);
 	if (pbase == NULL) {
-		if (sel->pid != -1) {
+		if (sel->pid != (pid_t)-1) {
 			nproc = 0;
 		} else {
 			(void) fprintf(stderr, "top: Out of memory.\n");
@@ -680,7 +679,7 @@
 	lbase = kvm_getlwps(kd, -1, 0, sizeof(struct kinfo_lwp), &nlwp);
 	if (lbase == NULL) {
 #ifdef notyet
-		if (sel->pid != -1) {
+		if (sel->pid != (pid_t)-1) {
 			nproc = 0;
 			nlwp = 0;
 		}
@@ -716,7 +715,7 @@
 	memset((char *)process_states, 0, sizeof(process_states));
 	lrefp = lref;
 	for (lp = lbase, i = 0; i < nlwp; lp++, i++) {
-		if (sel->pid != -1 && sel->pid != lp->l_pid)
+		if (sel->pid != (pid_t)-1 && sel->pid != (pid_t)lp->l_pid)
 			continue;
 
 		/*
@@ -731,7 +730,7 @@
 			if (lp->l_stat != LSZOMB &&
 			    (show_idle || (lp->l_pctcpu != 0) || 
 			    (lp->l_stat == LSRUN || lp->l_stat == LSONPROC)) &&
-			    (!show_uid || uid_from_thread(lp) == (uid_t)sel->uid)) {
+			    (!show_uid || uid_from_thread(lp) == sel->uid)) {
 				*lrefp++ = lp;
 				active_lwps++;
 			}
@@ -779,7 +778,7 @@
 #endif
 	char wmesg[KI_WMESGLEN + 1];
 	static char fmt[MAX_COLS];		/* static area where result is built */
-	char *pretty = "";
+	const char *pretty = "";
 
 	/* find and remember the next proc structure */
 	hp = (struct handle *)handle;
@@ -869,12 +868,13 @@
 	double pct;
 	struct handle *hp;
 	const char *statep;
+	static char gone[] = "<gone>";
 #ifdef KI_NOCPU
 	char state[10];
 #endif
 	char wmesg[KI_WMESGLEN + 1];
 	static char fmt[MAX_COLS];		/* static area where result is built */
-	char *pretty = "";
+	const char *pretty = "";
 	char *comm;
 	int uid;
 
@@ -912,7 +912,7 @@
 		}
 		uid = pp->p_ruid;
 	} else {
-		comm = "<gone>";
+		comm = gone;
 		uid = 0;
 	}
 
@@ -1043,7 +1043,7 @@
 		ORDERKEY_CPTICKS(l_)
 		ORDERKEY_STATE(l_)
 		ORDERKEY_PRIO(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1054,7 +1054,7 @@
 		ORDERKEY_PRIO(p_)
 		ORDERKEY_RSSIZE
 		ORDERKEY_MEM
-		;
+		return result;
 	}
 
 	return (result);
@@ -1077,7 +1077,7 @@
 		ORDERKEY_PCTCPU(l_)
 		ORDERKEY_CPTICKS(l_)
 		ORDERKEY_STATE(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1088,7 +1088,7 @@
 		ORDERKEY_STATE(p_)
 		ORDERKEY_RSSIZE
 		ORDERKEY_MEM
-		;
+		return result;
 	}
 
 	return (result);
@@ -1111,7 +1111,7 @@
 		ORDERKEY_CPTICKS(l_)
 		ORDERKEY_STATE(l_)
 		ORDERKEY_PRIO(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1122,7 +1122,7 @@
 		ORDERKEY_CPTICKS(p_)
 		ORDERKEY_STATE(p_)
 		ORDERKEY_PRIO(p_)
-		;
+		return result;
 	}
 
 	return (result);
@@ -1195,7 +1195,7 @@
 		ORDERKEY_CPTICKS(l_)
 		ORDERKEY_STATE(l_)
 		ORDERKEY_PRIO(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1206,7 +1206,7 @@
 		ORDERKEY_CPTICKS(p_)
 		ORDERKEY_STATE(p_)
 		ORDERKEY_PRIO(p_)
-		;
+		return result;
 	}
 
 	return (result);
@@ -1229,7 +1229,7 @@
 		ORDERKEY_PCTCPU(l_)
 		ORDERKEY_CPTICKS(l_)
 		ORDERKEY_PRIO(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1240,7 +1240,7 @@
 		ORDERKEY_PRIO(p_)
 		ORDERKEY_RSSIZE
 		ORDERKEY_MEM
-		;
+		return result;
 	}
 
 	return (result);
@@ -1263,7 +1263,7 @@
 		ORDERKEY_PCTCPU(l_)
 		ORDERKEY_STATE(l_)
 		ORDERKEY_PRIO(l_)
-		;
+		return result;
 	} else {
 		struct kinfo_proc2 *p1 = *(struct kinfo_proc2 **) pp1;
 		struct kinfo_proc2 *p2 = *(struct kinfo_proc2 **) pp2;
@@ -1274,7 +1274,7 @@
 		ORDERKEY_PRIO(p_)
 		ORDERKEY_MEM
 		ORDERKEY_RSSIZE
-		;
+		return result;
 	}
 
 	return (result);

Reply via email to