From owner-svn-src-head@freebsd.org Sat Jun 2 04:37:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A8B96EFD0FC; Sat, 2 Jun 2018 04:37:38 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5A16C6B273; Sat, 2 Jun 2018 04:37:38 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3A20F2BC4; Sat, 2 Jun 2018 04:37:38 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w524bcft084459; Sat, 2 Jun 2018 04:37:38 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w524bbRG084456; Sat, 2 Jun 2018 04:37:37 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806020437.w524bbRG084456@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sat, 2 Jun 2018 04:37:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334521 - head/usr.bin/top X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/usr.bin/top X-SVN-Commit-Revision: 334521 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2018 04:37:38 -0000 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 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[]);