* Paolo Bonzini (pbonz...@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<dgilb...@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 / dgilb...@redhat.com / Manchester, UK


Reply via email to