On Mon, Aug 19, 2024 at 16:38:28 +0200, Michal Privoznik wrote: > Instead of having many if-else statements, each with its own > vshTableRowAppend() call, we can use a simple trick - have an > array of string pointers, set array members in the if bodies and > then call vshTableRowAppend() once. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > tools/virsh-domain-monitor.c | 34 +++++++++++++--------------------- > 1 file changed, 13 insertions(+), 21 deletions(-) [...] > + if (vshTableRowAppend(table, id_buf, > + domName, stateStr, > + arg[0], arg[1], NULL) < 0) > + goto cleanup; While this works for this case when the arguments are at the end it will not work in others. When I've recently looked at that patch that motivated you to do this I thought it would be cool if vshTable would have a visibility flag for each column. That way you could always fill all of them and don't have to deal with such scenarios. > } else { > if (optUUID) { > if (virDomainGetUUIDString(dom, uuid) < 0) { anyways ... Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>