From owner-freebsd-audit Thu Aug 9 9:22: 9 2001 Delivered-To: freebsd-audit@freebsd.org Received: from panzer.kdm.org (panzer.kdm.org [216.160.178.169]) by hub.freebsd.org (Postfix) with ESMTP id 6444837B403 for ; Thu, 9 Aug 2001 09:22:05 -0700 (PDT) (envelope-from ken@panzer.kdm.org) Received: (from ken@localhost) by panzer.kdm.org (8.9.3/8.9.1) id KAA62685; Thu, 9 Aug 2001 10:21:40 -0600 (MDT) (envelope-from ken) Date: Thu, 9 Aug 2001 10:21:40 -0600 From: "Kenneth D. Merry" To: "Sergey A. Osokin" Cc: audit@FreeBSD.ORG Subject: Re: [PATCH] libdevstat have two compute statistics functions Message-ID: <20010809102140.A62588@panzer.kdm.org> References: <20010808184710.A87195@freebsd.org.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20010808184710.A87195@freebsd.org.ru>; from osa@freebsd.org.ru on Wed, Aug 08, 2001 at 06:47:11PM +0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Aug 08, 2001 at 18:47:11 +0400, Sergey A. Osokin wrote: > Hello. > After last commit into libdevstat, devstat.c containes > 2 compute statistics functions: old compute_stats() and > new devstat_compute_statistics(). > > I believe that compute_stats() is not necessary any more > and we should remove it. devstat_compute_statistics() is > a superset for compute_stats(). This patch won't work. The reason is that the arguments to compute_stats() can be NULL, which will cause it not to calculate that particular statistic. Your patch passes in all of the arguments to devstat_compute_statistics(). If one of the initial arguments is NULL, it will bail out and not compute the rest of the statistics. IMO this is the correct behavior -- the user has specified a statistic to calculate, and if he has not also given a valid variable to put the result in, that is an error. That is why I left the original compute_stats() in. The alternative would be to call devstat_compute_statistics() once for each argument, which would be inefficient. I think partially duplicated code is better than having to call devstat_compute_statistics() once for each variable. If there were a way to incrementally compose arguments to a function, that would be a reasonable way to handle things. > - return(0); > + return(devstat_compute_statistics(current, previous, etime, > + DSM_TOTAL_BYTES, total_bytes, > + DSM_TOTAL_TRANSFERS, total_transfers, > + DSM_TOTAL_BLOCKS, total_blocks, > + DSM_KB_PER_TRANSFER, kb_per_transfer, > + DSM_TRANSFERS_PER_SECOND, transfers_per_second, > + DSM_MB_PER_SECOND, mb_per_second, > + DSM_BLOCKS_PER_SECOND, blocks_per_second, > + DSM_MS_PER_TRANSACTION, ms_per_transaction, > + DSM_NONE)); > } > > long double Ken -- Kenneth Merry ken@kdm.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message