svn commit: r334524 - head/usr.bin/top

Eitan Adler eadler at FreeBSD.org
Sat Jun 2 07:44:52 UTC 2018


Author: eadler
Date: Sat Jun  2 07:44:50 2018
New Revision: 334524
URL: https://svnweb.freebsd.org/changeset/base/334524

Log:
  top(1): const poison part 2
  
  Further reduce the number of warnings emitted by gcc.

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

Modified: head/usr.bin/top/display.c
==============================================================================
--- head/usr.bin/top/display.c	Sat Jun  2 06:40:15 2018	(r334523)
+++ head/usr.bin/top/display.c	Sat Jun  2 07:44:50 2018	(r334524)
@@ -945,7 +945,7 @@ display_header(int t)
 }
 
 void
-new_message(int type, char *msgfmt, ...)
+new_message(int type, const char *msgfmt, ...)
 {
     va_list args;
     size_t i;

Modified: head/usr.bin/top/display.h
==============================================================================
--- head/usr.bin/top/display.h	Sat Jun  2 06:40:15 2018	(r334523)
+++ head/usr.bin/top/display.h	Sat Jun  2 07:44:50 2018	(r334524)
@@ -1,8 +1,6 @@
 /* $FreeBSD$ */
 /* constants needed for display.c */
 
-/* "type" argument for new_message function */
-
 #define  MT_standout  1
 #define  MT_delayed   2
 
@@ -26,7 +24,7 @@ void	 i_procstates(int total, int *brkdn);
 void	 i_swap(int *stats);
 void	 i_timeofday(time_t *tod);
 void	 i_uptime(struct timeval *bt, time_t *tod);
-void	 new_message(int type, char *msgfmt, ...);
+void	 new_message(int type, const char *msgfmt, ...);
 int	 readline(char *buffer, int size, int numeric);
 char	*trim_header(char *text);
 void	 u_arc(int *stats);

Modified: head/usr.bin/top/machine.c
==============================================================================
--- head/usr.bin/top/machine.c	Sat Jun  2 06:40:15 2018	(r334523)
+++ head/usr.bin/top/machine.c	Sat Jun  2 07:44:50 2018	(r334524)
@@ -119,7 +119,7 @@ static char up_header_tid_only[] =
 /* the extra nulls in the string "run" are for adding a slash and
    the processor number when needed */
 
-static char *state_abbrev[] = {
+static const char *state_abbrev[] = {
 	"", "START", "RUN\0\0\0", "SLEEP", "STOP", "ZOMB", "WAIT", "LOCK"
 };
 
@@ -1354,8 +1354,8 @@ static int sorted_state[] = {
 static int
 compare_cpu(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_PCTCPU(p1, p2);
 	ORDERKEY_CPTICKS(p1, p2);
@@ -1408,8 +1408,8 @@ int (*compares[])(const void *arg1, const void *arg2) 
 int
 compare_size(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_MEM(p1, p2);
 	ORDERKEY_RSSIZE(p1, p2);
@@ -1426,8 +1426,8 @@ compare_size(const void *arg1, const void *arg2)
 int
 compare_res(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_RSSIZE(p1, p2);
 	ORDERKEY_MEM(p1, p2);
@@ -1444,8 +1444,8 @@ compare_res(const void *arg1, const void *arg2)
 int
 compare_time(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const  *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *) arg2;
 
 	ORDERKEY_CPTICKS(p1, p2);
 	ORDERKEY_PCTCPU(p1, p2);
@@ -1462,8 +1462,8 @@ compare_time(const void *arg1, const void *arg2)
 int
 compare_prio(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_PRIO(p1, p2);
 	ORDERKEY_CPTICKS(p1, p2);
@@ -1479,8 +1479,8 @@ compare_prio(const void *arg1, const void *arg2)
 static int
 compare_threads(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_THREADS(p1, p2);
 	ORDERKEY_PCTCPU(p1, p2);
@@ -1497,8 +1497,8 @@ compare_threads(const void *arg1, const void *arg2)
 static int
 compare_jid(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc * const *)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc * const *)arg2;
 
 	ORDERKEY_JID(p1, p2);
 	ORDERKEY_PCTCPU(p1, p2);
@@ -1515,8 +1515,8 @@ compare_jid(const void *arg1, const void *arg2)
 static int
 compare_swap(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	const struct kinfo_proc *p1 = *(const struct kinfo_proc **)arg1;
+	const struct kinfo_proc *p2 = *(const struct kinfo_proc **)arg2;
 
 	ORDERKEY_SWAP(p1, p2);
 	ORDERKEY_PCTCPU(p1, p2);
@@ -1534,8 +1534,8 @@ compare_swap(const void *arg1, const void *arg2)
 int
 compare_iototal(const void *arg1, const void *arg2)
 {
-	struct kinfo_proc *p1 = *(struct kinfo_proc **)arg1;
-	struct kinfo_proc *p2 = *(struct kinfo_proc **)arg2;
+	struct kinfo_proc * const p1 = *(struct kinfo_proc **)arg1;
+	struct kinfo_proc * const p2 = *(struct kinfo_proc **)arg2;
 
 	return (get_io_total(p2) - get_io_total(p1));
 }


More information about the svn-src-head mailing list