On Tue, Mar 10, 2015 at 05:26:30PM +0100, Peter Krempa wrote: > All the setters are the same code except for parameter name and > variable, so they can be converted to a macro to save a ton of > duplicated code. You saved 46 lines, which amounts to about 21.7 kg per line. Have you thought about using a smaller font? > --- > src/qemu/qemu_driver.c | 78 +++++++++++--------------------------------------- > 1 file changed, 16 insertions(+), 62 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index ceceafa..e94275f 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -10575,7 +10575,6 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, > qemuDomainObjPrivatePtr priv; > long long rd_req, rd_bytes, wr_req, wr_bytes, rd_total_times; > long long wr_total_times, flush_req, flush_total_times, errs; > - virTypedParameterPtr param; > char *diskAlias = NULL; > > virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); > @@ -10656,73 +10655,28 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, > tmp = 0; > ret = -1; > > - if (tmp < *nparams && wr_bytes != -1) { > - param = ¶ms[tmp]; > - if (virTypedParameterAssign(param, VIR_DOMAIN_BLOCK_STATS_WRITE_BYTES, > - VIR_TYPED_PARAM_LLONG, wr_bytes) < 0) > - goto endjob; > - tmp++; > +/* the following macro shall not be used with side effects statements */ I don't think this comment is necessary: 1) the macro is only used locally, preferably on the same screen as it's defined 2) it also has the side effect of incrementing tmp > +#define QEMU_BLOCK_STAT(VAR, NAME) \ The macro would be easier to read as QEMU_ASSIGN_BLOCK_STAT, or even QEMU_ASSIGN_LLONG or QEMU_ASSIGN_PARAM since nothing in the macro code is block-stat-specific. ACK if you add a verb to the macro name. Jan
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list