[libvirt PATCH 2/4] remote: Drop useless check in remoteDispatchDomainGetIOThreadInfo

Jiri Denemark posted 4 patches 3 years ago
[libvirt PATCH 2/4] remote: Drop useless check in remoteDispatchDomainGetIOThreadInfo
Posted by Jiri Denemark 3 years ago
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/remote/remote_daemon_dispatch.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 4d993afee6..dbe6825fb8 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -2968,9 +2968,8 @@ remoteDispatchDomainGetIOThreadInfo(virNetServer *server G_GNUC_UNUSED,
     if (rv < 0)
         virNetMessageSaveError(rerr);
     virObjectUnref(dom);
-    if (ninfo >= 0)
-        for (i = 0; i < ninfo; i++)
-            virDomainIOThreadInfoFree(info[i]);
+    for (i = 0; i < ninfo; i++)
+        virDomainIOThreadInfoFree(info[i]);
     VIR_FREE(info);
 
     return rv;
-- 
2.39.1
Re: [libvirt PATCH 2/4] remote: Drop useless check in remoteDispatchDomainGetIOThreadInfo
Posted by Ján Tomko 3 years ago
On a Thursday in 2023, Jiri Denemark wrote:
>Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
>---

Can you elaborate on why you find this useless?

> src/remote/remote_daemon_dispatch.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
>diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
>index 4d993afee6..dbe6825fb8 100644
>--- a/src/remote/remote_daemon_dispatch.c
>+++ b/src/remote/remote_daemon_dispatch.c
>@@ -2968,9 +2968,8 @@ remoteDispatchDomainGetIOThreadInfo(virNetServer *server G_GNUC_UNUSED,
>     if (rv < 0)
>         virNetMessageSaveError(rerr);
>     virObjectUnref(dom);
>-    if (ninfo >= 0)

If ninfo is less than zero

>-        for (i = 0; i < ninfo; i++)

it will get promoted to unsigned here and the loop will take a long
time, freeing some fun stuff in the meantime.

Jano

>-            virDomainIOThreadInfoFree(info[i]);
>+    for (i = 0; i < ninfo; i++)
>+        virDomainIOThreadInfoFree(info[i]);
>     VIR_FREE(info);
>
>     return rv;
>-- 
>2.39.1
>
Re: [libvirt PATCH 2/4] remote: Drop useless check in remoteDispatchDomainGetIOThreadInfo
Posted by Jiri Denemark 3 years ago
On Thu, Jan 26, 2023 at 13:51:26 +0100, Ján Tomko wrote:
> On a Thursday in 2023, Jiri Denemark wrote:
> >Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> >---
> 
> Can you elaborate on why you find this useless?
> 
> > src/remote/remote_daemon_dispatch.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> >diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
> >index 4d993afee6..dbe6825fb8 100644
> >--- a/src/remote/remote_daemon_dispatch.c
> >+++ b/src/remote/remote_daemon_dispatch.c
> >@@ -2968,9 +2968,8 @@ remoteDispatchDomainGetIOThreadInfo(virNetServer *server G_GNUC_UNUSED,
> >     if (rv < 0)
> >         virNetMessageSaveError(rerr);
> >     virObjectUnref(dom);
> >-    if (ninfo >= 0)
> 
> If ninfo is less than zero
> 
> >-        for (i = 0; i < ninfo; i++)
> 
> it will get promoted to unsigned here and the loop will take a long
> time, freeing some fun stuff in the meantime.

Oops. Mostly because I didn't realize i is unsigned and I changed the
function so that ninfo cannot ever be negative (although I dropped the
change later anyway) :-)

Jirka