[PATCH 1/7] Avoid unnecessary nesting

Martin Kletzander posted 7 patches 3 years ago
[PATCH 1/7] Avoid unnecessary nesting
Posted by Martin Kletzander 3 years ago
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 src/qemu/qemu_hotplug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 026e1ee5add7..1fa3cc3ea9b1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2938,17 +2938,17 @@ qemuDomainAttachWatchdog(virDomainObj *vm,
 
     qemuAssignDeviceWatchdogAlias(watchdog);
 
-    if (watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) {
-        if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
-            goto cleanup;
-        releaseAddress = true;
-    } else {
+    if (watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                        _("hotplug of watchdog of model %s is not supported"),
                        virDomainWatchdogModelTypeToString(watchdog->model));
         goto cleanup;
     }
 
+    if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
+        goto cleanup;
+    releaseAddress = true;
+
     if (!(props = qemuBuildWatchdogDevProps(vm->def, watchdog)))
         goto cleanup;
 
-- 
2.39.1
Re: [PATCH 1/7] Avoid unnecessary nesting
Posted by Michal Prívozník 3 years ago
On 1/23/23 15:57, Martin Kletzander wrote:
> Signed-off-by: Martin Kletzander <mkletzan@redhat.com>


How about prefixing the subject with "qemuDomainAttachWatchdog: "?

> ---
>  src/qemu/qemu_hotplug.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 026e1ee5add7..1fa3cc3ea9b1 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -2938,17 +2938,17 @@ qemuDomainAttachWatchdog(virDomainObj *vm,
>  
>      qemuAssignDeviceWatchdogAlias(watchdog);
>  
> -    if (watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) {
> -        if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
> -            goto cleanup;
> -        releaseAddress = true;
> -    } else {
> +    if (watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB) {
>          virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
>                         _("hotplug of watchdog of model %s is not supported"),
>                         virDomainWatchdogModelTypeToString(watchdog->model));
>          goto cleanup;
>      }
>  
> +    if (qemuDomainEnsurePCIAddress(vm, &dev) < 0)
> +        goto cleanup;
> +    releaseAddress = true;
> +
>      if (!(props = qemuBuildWatchdogDevProps(vm->def, watchdog)))
>          goto cleanup;
>  

Michal