Re: [PATCH] lib: Drop intermediary return variables

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

 



On a Friday in 2021, Michal Privoznik wrote:
In a few places we declare a variable (which is optionally
followed by a code not touching it) then set the variable to a
value and return the variable immediately. It's obvious that the
variable is needless and the value can be returned directly
instead.

This patch was generated using this semantic patch:

 @@
 type T;
 identifier ret;
 expression E;
 @@
 - T ret;
 ... when != ret
     when strict
 - ret = E;
 - return ret;
 + return E;

After that I fixed couple of formatting issues because coccinelle
formatted some lines differently than our coding style.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
src/bhyve/bhyve_domain.c            |  6 +-----
src/conf/domain_addr.c              |  6 +-----
src/conf/domain_conf.c              |  5 +----
src/conf/virnetworkobj.c            |  4 +---
src/conf/virnwfilterbindingobj.c    |  5 +----
src/conf/virnwfilterobj.c           |  5 +----
src/esx/esx_driver.c                |  5 +----
src/esx/esx_storage_backend_iscsi.c |  5 +----
src/esx/esx_storage_backend_vmfs.c  |  5 +----
src/hyperv/hyperv_driver.c          |  5 +----
src/locking/lock_daemon.c           |  5 +----
src/locking/lock_driver_sanlock.c   |  6 ++----
src/logging/log_daemon.c            |  5 +----
src/network/bridge_driver.c         | 27 +++++----------------------
src/qemu/qemu_alias.c               | 24 ++++--------------------
src/qemu/qemu_command.c             | 15 ++++++---------
src/qemu/qemu_domain.c              | 10 +++-------
src/qemu/qemu_monitor.c             |  5 +----
src/security/security_apparmor.c    |  5 +----
src/security/security_nop.c         |  5 +----
src/test/test_driver.c              |  9 ++-------
src/util/viraudit.c                 |  4 +---
src/util/virfirewall.c              |  6 +-----
src/util/virmacmap.c                |  6 +-----
src/util/virnetdev.c                |  5 +----
src/util/virpci.c                   | 10 ++--------
src/vbox/vbox_common.c              |  7 +++----
tests/bhyvexml2argvmock.c           |  5 +----
tests/qemumonitortestutils.c        |  5 +----
tests/qemusecuritymock.c            |  6 +-----
tests/qemuxml2argvmock.c            |  5 +----
tests/virnetserverclienttest.c      |  6 +-----
tests/virpcimock.c                  |  8 ++------
tests/virusbmock.c                  |  4 +---
34 files changed, 54 insertions(+), 190 deletions(-)


Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

Attachment: signature.asc
Description: PGP signature


[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