diff mbox series

[PULL,3/6] migration/multifd: Fix loop conditions in multifd_zstd_send_prepare and multifd_zstd_recv

Message ID 20240917215506.472181-4-peterx@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,1/6] tests/qtest/migration: Move a couple of slow tests under g_test_slow | expand

Commit Message

Peter Xu Sept. 17, 2024, 9:55 p.m. UTC
From: Stefan Weil via <qemu-devel@nongnu.org>

GitHub's CodeQL reports four critical errors which are fixed by this commit:

    Unsigned difference expression compared to zero

An expression (u - v > 0) with unsigned values u, v is only false if u == v,
so all changed expressions did not work as expected.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Link: https://lore.kernel.org/r/20240910054138.1458555-1-sw@weilnetz.de
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/multifd-zstd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Stefan Weil Sept. 18, 2024, 5:47 a.m. UTC | #1
Am 17.09.24 um 23:55 schrieb Peter Xu:

> From: Stefan Weil via <qemu-devel@nongnu.org>


How can I avoid that my author name/email is changed so often?

Will this be fixed automatically before the commit is merged?

Stefan
Peter Xu Sept. 18, 2024, 1:17 p.m. UTC | #2
On Wed, Sep 18, 2024 at 07:47:42AM +0200, Stefan Weil wrote:
> Am 17.09.24 um 23:55 schrieb Peter Xu:
> 
> > From: Stefan Weil via <qemu-devel@nongnu.org>
> 
> 
> How can I avoid that my author name/email is changed so often?
> 
> Will this be fixed automatically before the commit is merged?

Hmm, this is pretty weird, as I actually did see this checkpatch error,
then I should have manually fixed the --author of your commit after queued,
as it was indeed mangled in the original patch:

https://lore.kernel.org/all/20240910054138.1458555-1-sw@weilnetz.de/

However it doesn't seem like working.. I checked again, that checkpatch
uses --no-mailmap so it still shows the mangled email.. I fixed it again
locally, then the error is gone.

Sorry, I don't know what happened, and why I used to fix it the same way
(that is, "git commit --author "XXX" --amend) but it didn't work last time
(but I guess .mailmap made it harder for me to recognize..).

It seems that we already have this:

commit 5204b499a6cae4dfd9fe762d5e6e82224892383b
Author: Philippe Mathieu-Daudé <philmd@linaro.org>
Date:   Thu Dec 8 16:55:35 2022 +0100

    mailmap: Fix Stefan Weil author email
 
So I assume even if Peter applies this PR it'll still show correct.

However if you (or Peter, any of you) prefer me to resend a pull, I can do
that too.  Let me know.

Thanks,
diff mbox series

Patch

diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
index 53da33e048..abed140855 100644
--- a/migration/multifd-zstd.c
+++ b/migration/multifd-zstd.c
@@ -123,9 +123,9 @@  static int multifd_zstd_send_prepare(MultiFDSendParams *p, Error **errp)
          */
         do {
             ret = ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush);
-        } while (ret > 0 && (z->in.size - z->in.pos > 0)
-                         && (z->out.size - z->out.pos > 0));
-        if (ret > 0 && (z->in.size - z->in.pos > 0)) {
+        } while (ret > 0 && (z->in.size > z->in.pos)
+                         && (z->out.size > z->out.pos));
+        if (ret > 0 && (z->in.size > z->in.pos)) {
             error_setg(errp, "multifd %u: compressStream buffer too small",
                        p->id);
             return -1;
@@ -243,7 +243,7 @@  static int multifd_zstd_recv(MultiFDRecvParams *p, Error **errp)
          */
         do {
             ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
-        } while (ret > 0 && (z->in.size - z->in.pos > 0)
+        } while (ret > 0 && (z->in.size > z->in.pos)
                          && (z->out.pos < page_size));
         if (ret > 0 && (z->out.pos < page_size)) {
             error_setg(errp, "multifd %u: decompressStream buffer too small",