All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	 Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [PULL 12/15] migration/block: rename BLOCK_SIZE macro
Date: Thu, 12 May 2022 17:22:24 +0100	[thread overview]
Message-ID: <CAFEAcA_jQRop9BjOG=7cUBPcuvgAZaQOAbkHTdgWeuxrK5+u+A@mail.gmail.com> (raw)
In-Reply-To: <20200228092420.103757-13-quintela@redhat.com>

On Fri, 28 Feb 2020 at 09:30, Juan Quintela <quintela@redhat.com> wrote:
>
> From: Stefan Hajnoczi <stefanha@redhat.com>
>
> Both <linux/fs.h> and <sys/mount.h> define BLOCK_SIZE macros.  Avoiding
> using that name in block/migration.c.
>
> I noticed this when including <liburing.h> (Linux io_uring) from
> "block/aio.h" and compilation failed.  Although patches adding that
> include haven't been sent yet, it makes sense to rename the macro now in
> case someone else stumbles on it in the meantime.

A rather old change, and it didn't even introduce the code that
Coverity is complaining about, but this seems as good a point as
any to hang the email off of...

BLK_MIG_BLOCK_SIZE doesn't have a ULL suffix, so it's 32 bits,
and so Coverity complains about places where we multiply some
block count by it and then use that in a 64-bit result, eg here:

> @@ -770,7 +771,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
>
>      /* control the rate of transfer */
>      blk_mig_lock();
> -    while (block_mig_state.read_done * BLOCK_SIZE <
> +    while (block_mig_state.read_done * BLK_MIG_BLOCK_SIZE <
>             qemu_file_get_rate_limit(f) &&
>             block_mig_state.submitted < MAX_PARALLEL_IO &&
>             (block_mig_state.submitted + block_mig_state.read_done) <

and here:

> @@ -874,13 +875,13 @@ static void block_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,
>      qemu_mutex_unlock_iothread();
>
>      blk_mig_lock();
> -    pending += block_mig_state.submitted * BLOCK_SIZE +
> -               block_mig_state.read_done * BLOCK_SIZE;
> +    pending += block_mig_state.submitted * BLK_MIG_BLOCK_SIZE +
> +               block_mig_state.read_done * BLK_MIG_BLOCK_SIZE;
>      blk_mig_unlock();

Putting a suitable cast to ensure the multiply is done at
64 bits would satisfy Coverity.

This is CID 1487136, 1487175.

thanks
-- PMM


  reply	other threads:[~2022-05-12 16:32 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-28  9:24 [PULL 00/15] Pull migration patches Juan Quintela
2020-02-28  9:24 ` [PULL 01/15] multifd: Add multifd-compression parameter Juan Quintela
2020-02-28  9:24 ` [PULL 02/15] migration: Add support for modules Juan Quintela
2020-02-28  9:24 ` [PULL 03/15] multifd: Make no compression operations into its own structure Juan Quintela
2022-04-12 19:04   ` Peter Maydell
2022-05-13 17:56     ` Peter Maydell
2022-07-19 14:06       ` Peter Maydell
2022-07-19 14:52     ` Markus Armbruster
2020-02-28  9:24 ` [PULL 04/15] multifd: Add multifd-zlib-level parameter Juan Quintela
2020-02-28  9:24 ` [PULL 05/15] multifd: Add zlib compression multifd support Juan Quintela
2020-02-28  9:24 ` [PULL 06/15] configure: Enable test and libs for zstd Juan Quintela
2020-02-29 20:06   ` Richard Henderson
2020-03-02  8:00     ` Juan Quintela
2020-03-02  8:32       ` Alex Bennée
2020-03-17 17:09   ` Peter Maydell
2020-03-17 17:40     ` Juan Quintela
2020-02-28  9:24 ` [PULL 07/15] multifd: Add multifd-zstd-level parameter Juan Quintela
2020-02-28  9:24 ` [PULL 08/15] multifd: Add zstd compression multifd support Juan Quintela
2020-02-28  9:24 ` [PULL 09/15] migration/vmstate: Remove redundant statement in vmstate_save_state_v() Juan Quintela
2020-02-28  9:24 ` [PULL 10/15] test-vmstate: Fix memleaks in test_load_qlist Juan Quintela
2020-02-28  9:24 ` [PULL 11/15] migration/savevm: release gslist after dump_vmstate_json Juan Quintela
2020-02-28  9:24 ` [PULL 12/15] migration/block: rename BLOCK_SIZE macro Juan Quintela
2022-05-12 16:22   ` Peter Maydell [this message]
2020-02-28  9:24 ` [PULL 13/15] migration: fix COLO broken caused by a previous commit Juan Quintela
2020-02-28  9:24 ` [PULL 14/15] migration/colo: wrap incoming checkpoint process into new helper Juan Quintela
2020-02-28  9:24 ` [PULL 15/15] savevm: Don't call colo_init_ram_cache twice Juan Quintela
2020-02-28 16:01 ` [PULL 00/15] Pull migration patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFEAcA_jQRop9BjOG=7cUBPcuvgAZaQOAbkHTdgWeuxrK5+u+A@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.