From owner-freebsd-bugs@FreeBSD.ORG Sun Jul 3 00:48:55 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 466EA16A420 for ; Sun, 3 Jul 2005 00:48:55 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04D5244A9B for ; Sun, 3 Jul 2005 00:30:58 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j630Uwnd015192 for ; Sun, 3 Jul 2005 00:30:58 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j630UwX6015191; Sun, 3 Jul 2005 00:30:58 GMT (envelope-from gnats) Resent-Date: Sun, 3 Jul 2005 00:30:58 GMT Resent-Message-Id: <200507030030.j630UwX6015191@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Nelson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D72716A4A1 for ; Sun, 3 Jul 2005 00:24:04 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C37143F83 for ; Sun, 3 Jul 2005 00:16:16 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.13.1/8.13.3) id j630GGE5088630; Sat, 2 Jul 2005 19:16:16 -0500 (CDT) (envelope-from dan) Message-Id: <200507030016.j630GGE5088630@dan.emsphone.com> Date: Sat, 2 Jul 2005 19:16:16 -0500 (CDT) From: Dan Nelson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/82909: [PATCH] fix ministat -s with >2 datasets X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2005 00:48:55 -0000 >Number: 82909 >Category: bin >Synopsis: [PATCH] fix ministat -s with >2 datasets >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jul 03 00:30:58 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Dan Nelson >Release: FreeBSD 5.4-STABLE i386 >Organization: The Allant Group >Environment: System: FreeBSD dan.emsphone.com 5.4-STABLE FreeBSD 5.4-STABLE #411: Fri Jun 10 10:55:56 CDT 2005 zsh@dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386 >Description: In 2003, a -s flag was added to ministat to separate the avg/median/stddev bars onto separate lines for readability if the ranges overlapped. In 2005, ministat was extended to support more than 2 datasets, but the -s code was not updated. It will coredump if run with -s and >2 sets. >How-To-Repeat: >Fix: Allocate the correct amount of memory to store all the bars in memory. ( newer version may be at http://dan.allantgroup.com/FreeBSD/ministat.diff ) Index: ministat.c =================================================================== RCS file: /home/ncvs/src/tools/tools/ministat/ministat.c,v retrieving revision 1.5 diff -u -p -r1.5 ministat.c --- ministat.c 27 May 2005 17:52:56 -0000 1.5 +++ ministat.c 30 Jun 2005 15:20:51 -0000 @@ -283,12 +283,13 @@ struct plot { char *data; char **bar; int separate_bars; + int num_datasets; }; static struct plot plot; static void -SetupPlot(int width, int separate) +SetupPlot(int width, int separate, int num_datasets) { struct plot *pl; @@ -298,6 +299,7 @@ SetupPlot(int width, int separate) pl->data = NULL; pl->bar = NULL; pl->separate_bars = separate; + pl->num_datasets = num_datasets; pl->min = 999e99; pl->max = -999e99; } @@ -344,8 +346,8 @@ PlotSet(struct dataset *ds, int val) bar = 0; if (pl->bar == NULL) { - pl->bar = malloc(sizeof(char *) * 2); - memset(pl->bar, 0, sizeof(char*) * 2); + pl->bar = malloc(sizeof(char *) * pl->num_datasets); + memset(pl->bar, 0, sizeof(char*) * pl->num_datasets); } if (pl->bar[bar] == NULL) { pl->bar[bar] = malloc(pl->width); @@ -426,7 +428,7 @@ DumpPlot(void) putchar('|'); putchar('\n'); } - for (i = 0; i < 2; i++) { + for (i = 0; i < pl->num_datasets; i++) { if (pl->bar[i] == NULL) continue; putchar('|'); @@ -568,7 +570,7 @@ main(int argc, char **argv) } if (!flag_n) { - SetupPlot(74, flag_s); + SetupPlot(74, flag_s, nds); for (i = 0; i < nds; i++) DimPlot(ds[i]); for (i = 0; i < nds; i++) >Release-Note: >Audit-Trail: >Unformatted: