Re: [PATCH 4/9] util: simplify virPCIProbeStubDriver()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 20, 2020 at 10:26:04PM -0400, Laine Stump wrote:
> This function had a loop that was only executed twice; it was
> artificially constructed with a label, a goto, and a boolean to tell
> that it had already been executed once. Aside from that, the body of
> the loop contained only two lines that needed to be repeated (the
> second time through, everything beyond those two lines would be
> skipped).
> 
> One side effect of this strange loop was that a g_autofree string was
> manually freed and re-initialized; I've been told that manually
> freeing a g_auto_free object is highly discouraged.
> 
> This patch refactors the function to simply repeat the 2 lines that
> might possibly be executed twice, thus eliminating the ugly use of
> goto to construct a loop, and also takes advantage of the fact that
> virPCIDriverDir() was previously returning *exactly* the same string
> both times it was called to eliminate the manual VIR_FREE of drvpath.
> 
> Signed-off-by: Laine Stump <laine@xxxxxxxxxx>

Much better :)
Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx>




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux