On Tue, Jul 18, 2017 at 03:41:22PM +0200, Markus Armbruster wrote: > The bulk of hmp_migrate_set_parameter()'s code sets one member of > MigrationParameters according to the command's arguments. It uses a > string visitor for integer and boolean members, but not for string and > size members. It calls visit_type_bool() right away, but delays > visit_type_int() some. The delaying requires a flag variable and a > bit of trickery: we set all integer members instead of just the one we > want, and rely on the has_FOOs to mask the unwanted ones. > > Clean this up as follows. Don't delay calling visit_type_int(). Use > the string visitor for strings, too. This involves extra allocations > and cleanup, but doing them is simpler and cleaner than avoiding them. > > Sadly, using the string visitor for sizes isn't possible, because it > defaults to Bytes rather than Mebibytes. Add a comment explaining > that. > > Signed-off-by: Markus Armbruster <arm...@redhat.com> > --- > hmp.c | 78 > ++++++++++++++++++++++++++++--------------------------------------- > 1 file changed, 32 insertions(+), 46 deletions(-)
Reviewed-by: Daniel P. Berrange <berra...@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|