svn commit: r332671 - head/contrib/top

Kurt Lidl lidl at FreeBSD.org
Wed Apr 18 13:17:16 UTC 2018


Author: lidl
Date: Wed Apr 18 13:17:14 2018
New Revision: 332671
URL: https://svnweb.freebsd.org/changeset/base/332671

Log:
  top: fix warnings from clang/gcc
  
  Add includes for <curses.h> and <termcap.h> where necessary, and
  rename a few internal functions to have a "top_" prefix to avoid
  clashes with standard names from curses.h/termcap.h headers.
  
  Top now compiles without warnings on both gcc and clang.
  
  Reviewed by:	emaste, imp, jhb
  MFC after:	3 days
  Differential Revision:	https://reviews.freebsd.org/D15115

Modified:
  head/contrib/top/display.c
  head/contrib/top/screen.c
  head/contrib/top/screen.h
  head/contrib/top/top.c

Modified: head/contrib/top/display.c
==============================================================================
--- head/contrib/top/display.c	Wed Apr 18 12:56:17 2018	(r332670)
+++ head/contrib/top/display.c	Wed Apr 18 13:17:14 2018	(r332671)
@@ -32,7 +32,9 @@
 
 #include <sys/time.h>
 
+#include <curses.h>
 #include <ctype.h>
+#include <termcap.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -255,7 +257,7 @@ double *avenrun;
     register int i;
 
     /* i_loadave also clears the screen, since it is first */
-    clear();
+    top_clear();
 
     /* mpid == -1 implies this system doesn't have an _mpid */
     if (mpid != -1)
@@ -796,7 +798,7 @@ i_message()
     }
     if (next_msg[0] != '\0')
     {
-	standout(next_msg);
+	top_standout(next_msg);
 	msglen = strlen(next_msg);
 	next_msg[0] = '\0';
     }
@@ -1076,7 +1078,7 @@ caddr_t a1, a2, a3;
 	    i = strlen(next_msg);
 	    if ((type & MT_delayed) == 0)
 	    {
-		type & MT_standout ? standout(next_msg) :
+		type & MT_standout ? top_standout(next_msg) :
 		                     fputs(next_msg, stdout);
 		(void) clear_eol(msglen - i);
 		msglen = i;
@@ -1088,7 +1090,7 @@ caddr_t a1, a2, a3;
     {
 	if ((type & MT_delayed) == 0)
 	{
-	    type & MT_standout ? standout(next_msg) : fputs(next_msg, stdout);
+	    type & MT_standout ? top_standout(next_msg) : fputs(next_msg, stdout);
 	    msglen = strlen(next_msg);
 	    next_msg[0] = '\0';
 	}

Modified: head/contrib/top/screen.c
==============================================================================
--- head/contrib/top/screen.c	Wed Apr 18 12:56:17 2018	(r332670)
+++ head/contrib/top/screen.c	Wed Apr 18 13:17:14 2018	(r332671)
@@ -45,6 +45,8 @@
 #  endif
 # endif
 #endif
+#include <curses.h>
+#include <termcap.h>
 #include "screen.h"
 #include "boolean.h"
 
@@ -432,10 +434,7 @@ get_screensize()
 }
 
 void
-standout(msg)
-
-char *msg;
-
+top_standout(char *msg)
 {
     if (smart_terminal)
     {
@@ -450,8 +449,7 @@ char *msg;
 }
 
 void
-clear()
-
+top_clear()
 {
     if (smart_terminal)
     {
@@ -460,10 +458,7 @@ clear()
 }
 
 int
-clear_eol(len)
-
-int len;
-
+clear_eol(int len)
 {
     if (smart_terminal && !overstrike && len > 0)
     {
@@ -496,12 +491,8 @@ go_home()
 
 /* This has to be defined as a subroutine for tputs (instead of a macro) */
 
-void
-putstdout(ch)
-
-char ch;
-
+int
+putstdout(int ch)
 {
-    putchar(ch);
+    return putchar(ch);
 }
-

Modified: head/contrib/top/screen.h
==============================================================================
--- head/contrib/top/screen.h	Wed Apr 18 12:56:17 2018	(r332670)
+++ head/contrib/top/screen.h	Wed Apr 18 13:17:14 2018	(r332671)
@@ -28,10 +28,10 @@ extern int  screen_length;
 extern int  screen_width;
 
 /* a function that puts a single character on stdout */
-void	putstdout(char ch);
+int		putstdout(int ch);
 int		clear_eol(int len);
-void	standout(char *msg);
-void	clear(void);
+void	top_standout(char *msg);
+void	top_clear(void);
 void	go_home(void);
 void	reinit_screen(void);
 void	get_screensize(void);

Modified: head/contrib/top/top.c
==============================================================================
--- head/contrib/top/top.c	Wed Apr 18 12:56:17 2018	(r332670)
+++ head/contrib/top/top.c	Wed Apr 18 13:17:14 2018	(r332671)
@@ -39,6 +39,7 @@ char *copyright =
 #include <sys/time.h>
 
 #include <ctype.h>
+#include <curses.h>
 #include <errno.h>
 #include <jail.h>
 #include <setjmp.h>
@@ -79,7 +80,7 @@ int pcpu_stats = No;
 sigret_t leave();
 sigret_t tstop();
 #ifdef SIGWINCH
-sigret_t winch();
+sigret_t top_winch(int);
 #endif
 
 volatile sig_atomic_t leaveflag;
@@ -682,7 +683,7 @@ char *argv[];
     (void) signal(SIGQUIT, leave);
     (void) signal(SIGTSTP, tstop);
 #ifdef SIGWINCH
-    (void) signal(SIGWINCH, winch);
+    (void) signal(SIGWINCH, top_winch);
 #endif
 #ifdef SIGRELSE
     sigrelse(SIGINT);
@@ -897,7 +898,7 @@ restart:
 		    max_topn = display_resize();
 
 		    /* reset the signal handler */
-		    (void) signal(SIGWINCH, winch);
+		    (void) signal(SIGWINCH, top_winch);
 
 		    reset_display();
 		    winchflag = 0;
@@ -971,9 +972,9 @@ restart:
 			    case CMD_help1:	/* help */
 			    case CMD_help2:
 				reset_display();
-				clear();
+				top_clear();
 				show_help();
-				standout("Hit any key to continue: ");
+				top_standout("Hit any key to continue: ");
 				fflush(stdout);
 				(void) read(0, &ch, 1);
 				break;
@@ -989,9 +990,9 @@ restart:
 				else
 				{
 				    reset_display();
-				    clear();
+				    top_clear();
 				    show_errors();
-				    standout("Hit any key to continue: ");
+				    top_standout("Hit any key to continue: ");
 				    fflush(stdout);
 				    (void) read(0, &ch, 1);
 				}
@@ -1300,10 +1301,7 @@ int i;
 }
 
 #ifdef SIGWINCH
-sigret_t winch(i)		/* SIGWINCH handler */
-
-int i;
-
+sigret_t top_winch(int i)		/* SIGWINCH handler */
 {
     winchflag = 1;
 }


More information about the svn-src-all mailing list