[pve-devel] [PATCH v2 qemu-server 4/4] qmeventd: VMID from PID: avoid goto

Fiona Ebner f.ebner at proxmox.com
Mon Jul 10 10:53:02 CEST 2023


If strtol() returns an errno, make sure not to print the error message
twice after the refactoring.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

New in v2.

 qmeventd/qmeventd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/qmeventd/qmeventd.c b/qmeventd/qmeventd.c
index 76a894cb..002b2ac4 100644
--- a/qmeventd/qmeventd.c
+++ b/qmeventd/qmeventd.c
@@ -134,20 +134,18 @@ get_vmid_from_pid(pid_t pid)
 	    continue;
 	}
 	if (errno != 0) {
-	    fprintf(stderr, "error parsing vmid for %d: %s\n", pid, strerror(errno));
 	    vmid = 0;
 	}
 
-	goto ret;
+	break;
     }
 
     if (errno) {
 	fprintf(stderr, "error parsing vmid for %d: %s\n", pid, strerror(errno));
-    } else {
+    } else if (!vmid) {
 	fprintf(stderr, "error parsing vmid for %d: no matching qemu.slice cgroup entry\n", pid);
     }
 
-ret:
     free(buf);
     fclose(fp);
     return vmid;
-- 
2.39.2






More information about the pve-devel mailing list