Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Jun 2018 04:37:37 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334521 - head/usr.bin/top
Message-ID:  <201806020437.w524bbRG084456@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Sat Jun  2 04:37:37 2018
New Revision: 334521
URL: https://svnweb.freebsd.org/changeset/base/334521

Log:
  top(1): const poison
  
  top(1) has a number of issues with writing to const strings. Begin
  helping this along by marking easy cases as const.

Modified:
  head/usr.bin/top/utils.c
  head/usr.bin/top/utils.h

Modified: head/usr.bin/top/utils.c
==============================================================================
--- head/usr.bin/top/utils.c	Sat Jun  2 04:25:09 2018	(r334520)
+++ head/usr.bin/top/utils.c	Sat Jun  2 04:37:37 2018	(r334521)
@@ -20,7 +20,7 @@
 #include <string.h>
 
 int
-atoiwi(char *str)
+atoiwi(const char *str)
 {
     int len;
 
@@ -136,7 +136,7 @@ int digits(int val)
  */
 
 char *
-strecpy(char *to, char *from)
+strecpy(char *to, const char *from)
 {
     while ((*to++ = *from++) != '\0');
     return(--to);
@@ -147,7 +147,7 @@ strecpy(char *to, char *from)
  */
 
 int
-string_index(char *string, char *array[])
+string_index(const char *string, char *array[])
 {
     size_t i = 0;
 
@@ -170,9 +170,10 @@ string_index(char *string, char *array[])
  *	squat about quotes.
  */
 
-char **argparse(char *line, int *cntp)
+char **
+argparse(char *line, int *cntp)
 {
-    char *from;
+    const char *from;
     char *to;
     int cnt;
     int ch;

Modified: head/usr.bin/top/utils.h
==============================================================================
--- head/usr.bin/top/utils.h	Sat Jun  2 04:25:09 2018	(r334520)
+++ head/usr.bin/top/utils.h	Sat Jun  2 04:37:37 2018	(r334521)
@@ -10,15 +10,15 @@
  *  Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
  */
 
-int atoiwi(char *);
+int atoiwi(const char *);
 char *itoa(unsigned int);
 char *itoa7(unsigned int);
 int digits(int);
-char *strecpy(char *, char *);
+char *strecpy(char *, const char *);
 char **argparse(char *, int *);
 long percentages(int, int *, long *, long *, long *);
 char *format_time(long);
 char *format_k(int);
 char *format_k2(unsigned long long);
-int string_index(char *string, char **array);
+int string_index(const char *string, char *array[]);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806020437.w524bbRG084456>