[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first
From: |
Nir Soffer |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block |
Date: |
Mon, 26 Aug 2019 18:23:00 +0300 |
On Mon, Aug 26, 2019 at 4:49 PM Eric Blake <address@hidden> wrote:
>
> On 8/26/19 7:31 AM, Max Reitz wrote:
>
> >> # the file size. This function hides the resulting difference in the
> >> # stat -c '%b' output.
> >> # Parameter 1: Number of blocks an empty file occupies
> >> -# Parameter 2: Image size in bytes
> >> +# Parameter 2: Minimal number of blocks in an image
> >> +# Parameter 3: Image size in bytes
> >> _filter_blocks()
> >> {
> >> extra_blocks=$1
> >> - img_size=$2
> >> + min_blocks=$2
> >> + img_size=$3
> >>
> >> - sed -e "s/blocks=$extra_blocks\\(\$\\|[^0-9]\\)/nothing allocated/" \
> >> - -e "s/blocks=$((extra_blocks + img_size /
> >> 512))\\(\$\\|[^0-9]\\)/everything allocated/"
> >> + sed -e "s/blocks=$((min_blocks))\\(\$\\|[^0-9]\\)/min allocation/" \
> >
> > Superfluous parentheses ($(())), but not wrong.
>
> Note that $((..)) has a purpose: it can convert any variable content
> into decimal. I can write min_blocks=0x1000, and $((min_blocks))
> results in 4096 while $min_blocks is still 0x1000. But I'd need more
> context as to what the callers expect to pass as to whether the $((...))
> is superfluous here.
In this case min_blocks is computed and always use base 10, so we don't
need the $(()).
Nir
Re: [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing, no-reply, 2019/08/25