[Libguestfs] [v2v PATCH 2/2] lib/utils: get_disk_allocated: adopt the int64 element type for "entries"

Laszlo Ersek lersek at redhat.com
Mon Jan 17 09:59:06 UTC 2022


On 01/14/22 15:07, Richard W.M. Jones wrote:
> On Fri, Jan 14, 2022 at 02:50:48PM +0100, Laszlo Ersek wrote:
>> Adapt our "Utils.get_disk_allocated" function to the changed signature of
>> "NBD.block_status", coming from libnbd patch
>>
>>   ocaml: map C's uint32_t to OCaml's int64
>>
>> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2027598
>> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
>> ---
>>  lib/utils.ml | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/utils.ml b/lib/utils.ml
>> index f599b0e32450..4c8998c28a3c 100644
>> --- a/lib/utils.ml
>> +++ b/lib/utils.ml
>> @@ -195,10 +195,10 @@ let get_disk_allocated ~dir ~disknr =
>>                 (fun ctx offset entries err ->
>>                    assert (ctx = alloc_ctx);
>>                    for i = 0 to Array.length entries / 2 - 1 do
>> -                    let len = Int64.of_int32 entries.(i * 2)
>> +                    let len = entries.(i * 2)
>>                      and typ = entries.(i * 2 + 1) in
>>                      assert (len > 0_L);
>> -                    if Int32.logand typ 1_l = 0_l then
>> +                    if typ &^ 1_L = 0_L then
>>                        allocated := !allocated +^ len;
>>                      fetch_offset := !fetch_offset +^ len
>>                    done;
> 
> ACK - even makes the code better :-)

Yes, I liked the &^ operator too :)

> Getting this into RHEL is going to be a pain, I will deal with the
> chain of builds once you've pushed this upstream.

Thanks -- I did the backports already (or should I say "some" backports,
as they were not reviewed), please see the links in the BZs (private
comments due to downstream branches and builds).

Thanks!
Laszlo

> 
> Thanks,
> 
> Rich.
> 




More information about the Libguestfs mailing list