Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/rndctl rndctl: make -l's "Flags" field reflect current ...
details: https://anonhg.NetBSD.org/src/rev/98f3a938864f
branches: trunk
changeset: 960900:98f3a938864f
user: nia <nia%NetBSD.org@localhost>
date: Fri Apr 02 07:17:56 2021 +0000
description:
rndctl: make -l's "Flags" field reflect current reality
don't print "legacy options" RND_FLAG_ESTIMATE_TIME and
"RND_FLAG_ESTIMATE_VALUE"
only print "estimate" if we have actually counted any bits from
something, since it's no longer really possible to "enable estimation".
ideally, there should also be a "samples" field so it's clear
collected bits are not being counted.
diffstat:
sbin/rndctl/rndctl.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diffs (80 lines):
diff -r 53c4a504ece2 -r 98f3a938864f sbin/rndctl/rndctl.c
--- a/sbin/rndctl/rndctl.c Fri Apr 02 07:09:11 2021 +0000
+++ b/sbin/rndctl/rndctl.c Fri Apr 02 07:17:56 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rndctl.c,v 1.37 2020/05/12 09:48:44 simonb Exp $ */
+/* $NetBSD: rndctl.c,v 1.38 2021/04/02 07:17:56 nia Exp $ */
/*-
* Copyright (c) 1997 Michael Graff.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.37 2020/05/12 09:48:44 simonb Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.38 2021/04/02 07:17:56 nia Exp $");
#endif
#include <sys/param.h>
@@ -75,7 +75,7 @@
static u_int32_t find_type(const char *name);
static const char *find_name(u_int32_t);
static void do_ioctl(rndctl_t *);
-static char * strflags(u_int32_t);
+static char * strflags(uint32_t, u_int32_t);
static void do_list(int, u_int32_t, char *);
static void do_stats(void);
@@ -444,29 +444,21 @@
}
static char *
-strflags(u_int32_t fl)
+strflags(uint32_t totalbits, u_int32_t fl)
{
static char str[512];
str[0] = '\0';
- if (fl & RND_FLAG_NO_ESTIMATE)
- ;
- else
+ if (totalbits > 0 && (fl & RND_FLAG_NO_ESTIMATE) == 0)
strlcat(str, "estimate, ", sizeof(str));
- if (fl & RND_FLAG_NO_COLLECT)
- ;
- else
+ if ((fl & RND_FLAG_NO_COLLECT) == 0)
strlcat(str, "collect, ", sizeof(str));
if (fl & RND_FLAG_COLLECT_VALUE)
strlcat(str, "v, ", sizeof(str));
if (fl & RND_FLAG_COLLECT_TIME)
strlcat(str, "t, ", sizeof(str));
- if (fl & RND_FLAG_ESTIMATE_VALUE)
- strlcat(str, "dv, ", sizeof(str));
- if (fl & RND_FLAG_ESTIMATE_TIME)
- strlcat(str, "dt, ", sizeof(str));
if (str[strlen(str) - 2] == ',')
str[strlen(str) - 2] = '\0';
@@ -500,7 +492,8 @@
rstat_name.source.rt.name,
rstat_name.source.rt.total,
find_name(rstat_name.source.rt.type),
- strflags(rstat_name.source.rt.flags));
+ strflags(rstat_name.source.rt.total,
+ rstat_name.source.rt.flags));
if (vflag) {
printf("\tDt samples = %d\n",
rstat_name.source.dt_samples);
@@ -538,7 +531,8 @@
rstat.source[i].rt.name,
rstat.source[i].rt.total,
find_name(rstat.source[i].rt.type),
- strflags(rstat.source[i].rt.flags));
+ strflags(rstat.source[i].rt.total,
+ rstat.source[i].rt.flags));
if (vflag) {
printf("\tDt samples = %d\n",
rstat.source[i].dt_samples);
Home |
Main Index |
Thread Index |
Old Index