[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 06/10] hmp: add basic "info stats" implementation
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH v5 06/10] hmp: add basic "info stats" implementation |
Date: |
Wed, 8 Jun 2022 16:23:55 +0100 |
User-agent: |
Mutt/2.2.1 (2022-02-19) |
* Paolo Bonzini (pbonzini@redhat.com) wrote:
> On 6/7/22 20:35, Dr. David Alan Gilbert wrote:
> > > + monitor_printf(mon, "%s", iec_binary_prefix(value->exponent));
> > OK that's better; but it's a shame the limits don't come from something
> > shared; iec_binary_prefix goes upto 60 and si_prefix goes way below -9
> >
> > Reviewed-by: Dr. David Alan Gilbert<dgilbert@redhat.com>
> >
>
> I can remove the limits altogether, and consider it a bug of the provider if
> they're not respected, but it's a bit ugly to have an assertion failure in
> that case.
[I just noticed si_prefix is declared to take 'unsigned int' which is
probably wrong)
Why don't you change the si_prefix/iec_binary_prefix to return NULL
rather than asserting, then we end up with something like:
exponentstr = NULL;
if (unit && value->base == 10) {
exponentstr = si_prefix(value->exponent);
} else if (unit && value->base == 2) {
exponentstr = iec_binary_prefix(value->exponent);
}
if (exponentstr) {
monitor_printf(mon, "%s", exponentstr);
} else if (value->exponent) {
Dave
> Paolo
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK