Author: eadler
Date: Mon May 21 03:36:16 2018
New Revision: 333958
URL: https://svnweb.freebsd.org/changeset/base/333958

Log:
  top(1): fix several more warnings

Modified:
  head/usr.bin/top/commands.c
  head/usr.bin/top/display.c
  head/usr.bin/top/machine.c
  head/usr.bin/top/screen.c
  head/usr.bin/top/top.c
  head/usr.bin/top/top.h
  head/usr.bin/top/utils.c

Modified: head/usr.bin/top/commands.c
==============================================================================
--- head/usr.bin/top/commands.c Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/commands.c Mon May 21 03:36:16 2018        (r333958)
@@ -326,8 +326,8 @@ static int
 err_compar(const void *p1, const void *p2)
 {
     int result;
-    struct errs * g1 = (struct errs *)p1;
-    struct errs * g2 = (struct errs *)p2;
+    const struct errs * const g1 = (const struct errs * const)p1;
+    const struct errs * const g2 = (const struct errs * const)p2;
 
 
 

Modified: head/usr.bin/top/display.c
==============================================================================
--- head/usr.bin/top/display.c  Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/display.c  Mon May 21 03:36:16 2018        (r333958)
@@ -66,7 +66,7 @@ static int display_width = MAX_COLS;
 /* things initialized by display_init and used thruout */
 
 /* buffer of proc information lines for display updating */
-char *screenbuf = NULL;
+static char *screenbuf = NULL;
 
 static char **procstate_names;
 static char **cpustate_names;
@@ -656,13 +656,10 @@ int *stats;
  *  Assumptions:  cursor is on "lastline"
  *                for i_arc ONLY: cursor is on the previous line
  */
-char arc_buffer[MAX_COLS];
+static char arc_buffer[MAX_COLS];
 
 void
-i_arc(stats)
-
-int *stats;
-
+i_arc(int *stats)
 {
     if (arc_names == NULL)
        return;
@@ -698,13 +695,10 @@ int *stats;
  *  Assumptions:  cursor is on "lastline"
  *                for i_carc ONLY: cursor is on the previous line
  */
-char carc_buffer[MAX_COLS];
+static char carc_buffer[MAX_COLS];
 
 void
-i_carc(stats)
-
-int *stats;
-
+i_carc(int *stats)
 {
     if (carc_names == NULL)
        return;
@@ -740,13 +734,10 @@ int *stats;
  *                for i_swap ONLY: cursor is on the previous line
  */
 
-char swap_buffer[MAX_COLS];
+static char swap_buffer[MAX_COLS];
 
 void
-i_swap(stats)
-
-int *stats;
-
+i_swap(int *stats)
 {
     fputs("\nSwap: ", stdout);
     lastline++;
@@ -757,10 +748,7 @@ int *stats;
 }
 
 void
-u_swap(stats)
-
-int *stats;
-
+u_swap(int *stats)
 {
     static char new[MAX_COLS];
 
@@ -790,8 +778,8 @@ static int msglen = 0;
 
 void
 i_message()
-
 {
+
     while (lastline < y_message)
     {
        fputc('\n', stdout);

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c  Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/machine.c  Mon May 21 03:36:16 2018        (r333958)
@@ -124,7 +124,7 @@ static char up_header[] =
 /* the extra nulls in the string "run" are for adding a slash and
    the processor number when needed */
 
-char *state_abbrev[] = {
+static char *state_abbrev[] = {
        "", "START", "RUN\0\0\0", "SLEEP", "STOP", "ZOMB", "WAIT", "LOCK"
 };
 
@@ -151,8 +151,8 @@ static long cp_diff[CPUSTATES];
 
 /* these are for detailing the process states */
 
-int process_states[8];
-char *procstatenames[] = {
+static int process_states[8];
+static char *procstatenames[] = {
        "", " starting, ", " running, ", " sleeping, ", " stopped, ",
        " zombie, ", " waiting, ", " lock, ",
        NULL
@@ -160,33 +160,33 @@ char *procstatenames[] = {
 
 /* these are for detailing the cpu states */
 
-int cpu_states[CPUSTATES];
-char *cpustatenames[] = {
+static int cpu_states[CPUSTATES];
+static char *cpustatenames[] = {
        "user", "nice", "system", "interrupt", "idle", NULL
 };
 
 /* these are for detailing the memory statistics */
 
-int memory_stats[7];
-char *memorynames[] = {
+static int memory_stats[7];
+static char *memorynames[] = {
        "K Active, ", "K Inact, ", "K Laundry, ", "K Wired, ", "K Buf, ",
        "K Free", NULL
 };
 
-int arc_stats[7];
-char *arcnames[] = {
+static int arc_stats[7];
+static char *arcnames[] = {
        "K Total, ", "K MFU, ", "K MRU, ", "K Anon, ", "K Header, ", "K Other",
        NULL
 };
 
-int carc_stats[4];
-char *carcnames[] = {
+static int carc_stats[4];
+static char *carcnames[] = {
        "K Compressed, ", "K Uncompressed, ", ":1 Ratio, ",
        NULL
 };
 
-int swap_stats[7];
-char *swapnames[] = {
+static int swap_stats[7];
+static char *swapnames[] = {
        "K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out",
        NULL
 };
@@ -933,7 +933,8 @@ format_next_process(caddr_t xhandle, char *(*get_useri
        size_t state;
        struct rusage ru, *rup;
        long p_tot, s_tot;
-       char *proc_fmt, thr_buf[6];
+       char *proc_fmt;
+       char thr_buf[6];
        char jid_buf[TOP_JID_LEN + 1], swap_buf[TOP_SWAP_LEN + 1];
        char *cmdbuf = NULL;
        char **args;

Modified: head/usr.bin/top/screen.c
==============================================================================
--- head/usr.bin/top/screen.c   Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/screen.c   Mon May 21 03:36:16 2018        (r333958)
@@ -32,9 +32,6 @@
 #include "screen.h"
 #include "boolean.h"
 
-extern char *myname;
-
-
 int  overstrike;
 int  screen_length;
 int  screen_width;

Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c      Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/top.c      Mon May 21 03:36:16 2018        (r333958)
@@ -1,6 +1,3 @@
-char *copyright =
-    "Copyright (c) 1984 through 1996, William LeFebvre";
-
 /*
  *  Top users/processes display for Unix
  *
@@ -43,10 +40,13 @@ char *copyright =
 /* Size of the stdio buffer given to stdout */
 #define Buffersize     2048
 
+char *copyright =
+    "Copyright (c) 1984 through 1996, William LeFebvre";
+
 typedef void sigret_t;
 
 /* The buffer that stdio will use */
-char stdoutbuf[Buffersize];
+static char stdoutbuf[Buffersize];
 
 /* build Signal masks */
 #define Smask(s)       (1 << ((s) - 1))
@@ -69,34 +69,30 @@ static int max_topn;                /* maximum displayable 
processes
 
 /* miscellaneous things */
 struct process_select ps;
-char *myname = "top";
-jmp_buf jmp_int;
+const char * myname = "top";
 
 char *username(int);
 
 time_t time(time_t *tloc);
 
-caddr_t get_process_info(struct system_info *si, struct process_select *sel,
-    int (*compare)(const void *, const void *));
-
 /* different routines for displaying the user's identification */
 /* (values assigned to get_userid) */
 char *username(int);
 char *itoa7(int);
 
 /* pointers to display routines */
-void (*d_loadave)(int mpid, double *avenrun) = i_loadave;
-void (*d_procstates)(int total, int *brkdn) = i_procstates;
-void (*d_cpustates)(int *states) = i_cpustates;
-void (*d_memory)(int *stats) = i_memory;
-void (*d_arc)(int *stats) = i_arc;
-void (*d_carc)(int *stats) = i_carc;
-void (*d_swap)(int *stats) = i_swap;
-void (*d_message)(void) = i_message;
-void (*d_header)(char *text) = i_header;
-void (*d_process)(int line, char *thisline) = i_process;
+static void (*d_loadave)(int mpid, double *avenrun) = i_loadave;
+static void (*d_procstates)(int total, int *brkdn) = i_procstates;
+static void (*d_cpustates)(int *states) = i_cpustates;
+static void (*d_memory)(int *stats) = i_memory;
+static void (*d_arc)(int *stats) = i_arc;
+static void (*d_carc)(int *stats) = i_carc;
+static void (*d_swap)(int *stats) = i_swap;
+static void (*d_message)(void) = i_message;
+static void (*d_header)(char *text) = i_header;
+static void (*d_process)(int line, char *thisline) = i_process;
 
-void reset_display(void);
+static void reset_display(void);
 
 static void
 reset_uids()
@@ -1177,7 +1173,7 @@ restart:
  *     screen will get redrawn.
  */
 
-void
+static void
 reset_display()
 
 {

Modified: head/usr.bin/top/top.h
==============================================================================
--- head/usr.bin/top/top.h      Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/top.h      Mon May 21 03:36:16 2018        (r333958)
@@ -46,6 +46,8 @@ extern enum displaymodes displaymode;
 extern int pcpu_stats;
 extern int  overstrike;
 
+extern const char * myname;
+
 extern int (*compares[])(const void*, const void*);
 
 char* kill_procs(char *);

Modified: head/usr.bin/top/utils.c
==============================================================================
--- head/usr.bin/top/utils.c    Mon May 21 01:53:23 2018        (r333957)
+++ head/usr.bin/top/utils.c    Mon May 21 03:36:16 2018        (r333958)
@@ -16,6 +16,7 @@
  */
 
 #include "top.h"
+#include "utils.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -428,10 +429,8 @@ int amt;
     return(ret);
 }
 
-char *format_k2(amt)
-
-unsigned long long amt;
-
+char *
+format_k2(unsigned long long amt)
 {
     static char retarray[NUM_STRINGS][16];
     static int index = 0;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to