From owner-svn-src-all@freebsd.org Sat Jun 2 04:20:44 2018 Return-Path: Delivered-To: svn-src-all@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 0679FEFAF98; Sat, 2 Jun 2018 04:20:44 +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 ACCE36A4CC; Sat, 2 Jun 2018 04:20:43 +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 8DFD528A5; Sat, 2 Jun 2018 04:20:43 +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 w524KhWN074559; Sat, 2 Jun 2018 04:20:43 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w524KhMb074558; Sat, 2 Jun 2018 04:20:43 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201806020420.w524KhMb074558@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:20:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334519 - 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: 334519 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Jun 2018 04:20:44 -0000 Author: eadler Date: Sat Jun 2 04:20:42 2018 New Revision: 334519 URL: https://svnweb.freebsd.org/changeset/base/334519 Log: top(1): clean up a bit - remove unused defines - use standard defines for STDOUT - don't cast for memset - avoid using (void) cast Modified: head/usr.bin/top/machine.c head/usr.bin/top/screen.c Modified: head/usr.bin/top/machine.c ============================================================================== --- head/usr.bin/top/machine.c Sat Jun 2 04:08:52 2018 (r334518) +++ head/usr.bin/top/machine.c Sat Jun 2 04:20:42 2018 (r334519) @@ -841,7 +841,7 @@ get_process_info(struct system_info *si, struct proces total_inblock = 0; total_oublock = 0; total_majflt = 0; - memset((char *)process_states, 0, sizeof(process_states)); + memset(process_states, 0, sizeof(process_states)); prefp = pref; for (pp = pbase, i = 0; i < nproc; pp++, i++) { Modified: head/usr.bin/top/screen.c ============================================================================== --- head/usr.bin/top/screen.c Sat Jun 2 04:08:52 2018 (r334518) +++ head/usr.bin/top/screen.c Sat Jun 2 04:20:42 2018 (r334519) @@ -20,15 +20,16 @@ * preprocessor variable "TOStop". --wnl */ -#include "top.h" - #include #include #include #include #include #include +#include + #include "screen.h" +#include "top.h" int overstrike; int screen_length; @@ -54,10 +55,6 @@ static struct termios old_settings; static struct termios new_settings; static char is_a_terminal = false; -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 - void init_termcap(int interactive) { @@ -164,7 +161,7 @@ init_termcap(int interactive) PC = (PCptr = tgetstr("pc", &bufptr)) ? *PCptr : 0; /* set convenience strings */ - (void) strncpy(home, tgoto(cursor_motion, 0, 0), sizeof(home) - 1); + strncpy(home, tgoto(cursor_motion, 0, 0), sizeof(home) - 1); home[sizeof(home) - 1] = '\0'; /* (lower_left is set in get_screensize) */ @@ -174,7 +171,7 @@ init_termcap(int interactive) get_screensize(); /* if stdout is not a terminal, pretend we are a dumb terminal */ - if (tcgetattr(STDOUT, &old_settings) == -1) + if (tcgetattr(STDOUT_FILENO, &old_settings) == -1) { smart_terminal = false; } @@ -184,7 +181,7 @@ void init_screen(void) { /* get the old settings for safe keeping */ - if (tcgetattr(STDOUT, &old_settings) != -1) + if (tcgetattr(STDOUT_FILENO, &old_settings) != -1) { /* copy the settings so we can modify them */ new_settings = old_settings; @@ -194,7 +191,7 @@ init_screen(void) new_settings.c_oflag &= ~(TAB3); new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; - (void) tcsetattr(STDOUT, TCSADRAIN, &new_settings); + tcsetattr(STDOUT_FILENO, TCSADRAIN, &new_settings); /* remember the erase and kill characters */ ch_erase = old_settings.c_cc[VERASE]; @@ -229,7 +226,7 @@ end_screen(void) /* if we have settings to reset, then do so */ if (is_a_terminal) { - (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings); + tcsetattr(STDOUT_FILENO, TCSADRAIN, &old_settings); } } @@ -239,7 +236,7 @@ reinit_screen(void) /* install our settings if it is a terminal */ if (is_a_terminal) { - (void) tcsetattr(STDOUT, TCSADRAIN, &new_settings); + tcsetattr(STDOUT_FILENO, TCSADRAIN, &new_settings); } /* send init string */