Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Aug 2001 10:21:40 -0600
From:      "Kenneth D. Merry" <ken@kdm.org>
To:        "Sergey A. Osokin" <osa@freebsd.org.ru>
Cc:        audit@FreeBSD.ORG
Subject:   Re: [PATCH] libdevstat have two compute statistics functions
Message-ID:  <20010809102140.A62588@panzer.kdm.org>
In-Reply-To: <20010808184710.A87195@freebsd.org.ru>; from osa@freebsd.org.ru on Wed, Aug 08, 2001 at 06:47:11PM %2B0400
References:  <20010808184710.A87195@freebsd.org.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010809102140.A62588>