On a Sunday in 2020, Laine Stump wrote:
In most cases this eliminates one or more calls to
virBufferClearAndReset(), but even when it doesn't it's better because:
1) it makes the code more consistent, making it more likely that new contributors who are
"learning by example" will to the right thing.
Long line
2) it protects against future modifications that might have otherwise
needed to add a virBufferClearAndReset()
3) Currently some functions don't call virBufferClearAndReset() only
because they're relying on some subordinate function to call it for
them (e.g. bhyveConnectGetSysinfo() in this patch relies on
virSysinfoFormat() to clear out the buffer when there is an error). I
think this is sloppy behavior, and that the toplevel function that
defines and initializes the buffer should be the function clearing it
at the end.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/bhyve/bhyve_command.c | 15 ++++++---------
src/bhyve/bhyve_driver.c | 4 ++--
2 files changed, 8 insertions(+), 11 deletions(-)
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano