[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: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/2] block: posix: Always allocate the first block |
Date: |
Mon, 26 Aug 2019 08:49:46 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
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.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
Re: [Qemu-devel] [PATCH v2 0/2] Optimize alignment probing, no-reply, 2019/08/25