From owner-svn-src-head@freebsd.org Thu Sep 10 22:07:54 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 464A3A02C60; Thu, 10 Sep 2015 22:07:54 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AD3B1987; Thu, 10 Sep 2015 22:07:54 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8AM7s4P020946; Thu, 10 Sep 2015 22:07:54 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8AM7rrb020941; Thu, 10 Sep 2015 22:07:53 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201509102207.t8AM7rrb020941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Thu, 10 Sep 2015 22:07:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287633 - head/usr.bin/systat X-SVN-Group: head 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.20 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: Thu, 10 Sep 2015 22:07:54 -0000 Author: delphij Date: Thu Sep 10 22:07:52 2015 New Revision: 287633 URL: https://svnweb.freebsd.org/changeset/base/287633 Log: - Avoid accessing window properties directly, instead, use accessors. This should be no-op for now, but allows the code to work if we move to NCURSES_OPAQUE. - Use calloc() instead of malloc+bzero. MFC after: 2 weeks Modified: head/usr.bin/systat/iostat.c head/usr.bin/systat/netstat.c head/usr.bin/systat/pigs.c head/usr.bin/systat/vmstat.c Modified: head/usr.bin/systat/iostat.c ============================================================================== --- head/usr.bin/systat/iostat.c Thu Sep 10 22:07:38 2015 (r287632) +++ head/usr.bin/systat/iostat.c Thu Sep 10 22:07:52 2015 (r287633) @@ -112,10 +112,8 @@ initiostat(void) if ((num_devices = devstat_getnumdevs(NULL)) < 0) return(0); - cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - bzero(cur.dinfo, sizeof(struct devinfo)); - bzero(last.dinfo, sizeof(struct devinfo)); + cur.dinfo = calloc(1, sizeof(struct devinfo)); + last.dinfo = calloc(1, sizeof(struct devinfo)); /* * This value for maxshowdevs (100) is bogus. I'm not sure exactly @@ -196,7 +194,7 @@ numlabels(int row) char tmpstr[10]; #define COLWIDTH 17 -#define DRIVESPERLINE ((wnd->_maxx - INSET) / COLWIDTH) +#define DRIVESPERLINE ((getmaxx(wnd) - 1 - INSET) / COLWIDTH) for (ndrives = 0, i = 0; i < num_devices; i++) if (dev_select[i].selected) ndrives++; @@ -204,7 +202,7 @@ numlabels(int row) /* * Deduct -regions for blank line after each scrolling region. */ - linesperregion = (wnd->_maxy - row - regions) / regions; + linesperregion = (getmaxy(wnd) - 1 - row - regions) / regions; /* * Minimum region contains space for two * label lines and one line of statistics. @@ -214,9 +212,9 @@ numlabels(int row) _col = INSET; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (_col + COLWIDTH >= wnd->_maxx - INSET) { + if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) { _col = INSET, row += linesperregion + 1; - if (row > wnd->_maxy - (linesperregion + 1)) + if (row > getmaxy(wnd) - 1 - (linesperregion + 1)) break; } sprintf(tmpstr, "%s%d", dev_select[i].device_name, @@ -241,7 +239,7 @@ barlabels(int row) linesperregion = 2 + kbpt; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (row > wnd->_maxy - linesperregion) + if (row > getmaxy(wnd) - 1 - linesperregion) break; sprintf(tmpstr, "%s%d", dev_select[i].device_name, dev_select[i].unit_number); @@ -276,7 +274,7 @@ showiostat(void) row += 2; for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (row > wnd->_maxy - linesperregion) + if (row > getmaxy(wnd) - linesperregion) break; row = devstats(row, INSET, i); } @@ -289,9 +287,9 @@ showiostat(void) winsertln(wnd); for (i = 0; i < num_devices; i++) if (dev_select[i].selected) { - if (_col + COLWIDTH >= wnd->_maxx - INSET) { + if (_col + COLWIDTH >= getmaxx(wnd) - 1 - INSET) { _col = INSET, row += linesperregion + 1; - if (row > wnd->_maxy - (linesperregion + 1)) + if (row > getmaxy(wnd) - 1 - (linesperregion + 1)) break; wmove(wnd, row + linesperregion, 0); wdeleteln(wnd); Modified: head/usr.bin/systat/netstat.c ============================================================================== --- head/usr.bin/systat/netstat.c Thu Sep 10 22:07:38 2015 (r287632) +++ head/usr.bin/systat/netstat.c Thu Sep 10 22:07:52 2015 (r287633) @@ -85,7 +85,7 @@ static char *inetname(struct sockaddr *) static void inetprint(struct sockaddr *, const char *); #define streq(a,b) (strcmp(a,b)==0) -#define YMAX(w) ((w)->_maxy-1) +#define YMAX(w) (getmaxy(w)-2) WINDOW * opennetstat(void) Modified: head/usr.bin/systat/pigs.c ============================================================================== --- head/usr.bin/systat/pigs.c Thu Sep 10 22:07:38 2015 (r287632) +++ head/usr.bin/systat/pigs.c Thu Sep 10 22:07:52 2015 (r287633) @@ -94,8 +94,8 @@ showpigs(void) qsort(pt, nproc, sizeof (struct p_times), compar); y = 1; i = nproc; - if (i > wnd->_maxy-1) - i = wnd->_maxy-1; + if (i > getmaxy(wnd)-2) + i = getmaxy(wnd)-2; for (k = 0; i > 0 && pt[k].pt_pctcpu > 0.01; i--, y++, k++) { uname = user_from_uid(pt[k].pt_kp->ki_uid, 0); pname = pt[k].pt_kp->ki_comm; Modified: head/usr.bin/systat/vmstat.c ============================================================================== --- head/usr.bin/systat/vmstat.c Thu Sep 10 22:07:38 2015 (r287632) +++ head/usr.bin/systat/vmstat.c Thu Sep 10 22:07:52 2015 (r287633) @@ -205,12 +205,9 @@ initkre(void) return(0); } - cur.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - last.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - run.dinfo = (struct devinfo *)malloc(sizeof(struct devinfo)); - bzero(cur.dinfo, sizeof(struct devinfo)); - bzero(last.dinfo, sizeof(struct devinfo)); - bzero(run.dinfo, sizeof(struct devinfo)); + cur.dinfo = calloc(1, sizeof(struct devinfo)); + last.dinfo = calloc(1, sizeof(struct devinfo)); + run.dinfo = calloc(1, sizeof(struct devinfo)); if (dsinit(MAXDRIVES, &cur, &last, &run) != 1) return(0);