aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEitan Adler <eadler@FreeBSD.org>2018-06-02 04:37:37 +0000
committerEitan Adler <eadler@FreeBSD.org>2018-06-02 04:37:37 +0000
commit66b3f031f02dcdca304d920930322c20659d30a5 (patch)
treed6e1524db96da4190ab3e64211c6daf2fb793643
parentdbe3061729e3b1b0a56370d529b4a3f90543a0c3 (diff)
downloadsrc-66b3f031f02dcdca304d920930322c20659d30a5.tar.gz
src-66b3f031f02dcdca304d920930322c20659d30a5.zip
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.
Notes
Notes: svn path=/head/; revision=334521
-rw-r--r--usr.bin/top/utils.c11
-rw-r--r--usr.bin/top/utils.h6
2 files changed, 9 insertions, 8 deletions
diff --git a/usr.bin/top/utils.c b/usr.bin/top/utils.c
index 4a8a0d8817d4..2278bd116797 100644
--- a/usr.bin/top/utils.c
+++ b/usr.bin/top/utils.c
@@ -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;
diff --git a/usr.bin/top/utils.h b/usr.bin/top/utils.h
index d04645dd8a17..a53e55bea090 100644
--- a/usr.bin/top/utils.h
+++ b/usr.bin/top/utils.h
@@ -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[]);