Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: refactor function to simplify and remove label
Once the DIR* in virPCIGetName() was made g_autoptr, the cleanup: label just had a "return ret;", but the rest of the function was more compilcated than it needed to be, doing funky things with the value of ret inside multi-level conditionals and a while loop that might exit early via a break with ret == 0 or exit early via a goto cleanup with ret == -1. It really didn't need to be nearly as complicated. After doing the trivial replacements of "goto cleanup" with appropriate direct returns, it became obvious that: 1) the outermost level of the nested conditional at the end of the function ("if (ret < 0)") was now redundant, since ret is now *always* < 0 by that point (otherwise the function has returned). 2) by switching the sense of the next level of the conditional (making it "if (!physPortID)", the "else" (which is now just "return 0;" becomes the "if", and the new "else" no longer needs to be inside the conditional. 3) the value of firstEntryName can be moved into *netname with g_steal_pointer() Once that is all done, ret is no longer used and can be removed. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
- Loading branch information