[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v3 17/39] qcow2: Update l2_allocate() to support
Re: [Qemu-block] [PATCH v3 17/39] qcow2: Update l2_allocate() to support L2 slices
Fri, 02 Feb 2018 10:41:09 +0100
Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu)
On Thu 01 Feb 2018 07:15:23 PM CET, Max Reitz <address@hidden> wrote:
>>>> -static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t
>>>> +static int l2_allocate(BlockDriverState *bs, int l1_index)
>>>> BDRVQcow2State *s = bs->opaque;
>>>> uint64_t old_l2_offset;
>>>> - uint64_t *l2_table = NULL;
>>>> + uint64_t *l2_slice = NULL;
>>>> + unsigned slice, slice_size2, n_slices;
>>> I'd personally prefer size_t, but oh well.
>> I don't see any reason not to use int / unsigned. The size of a slice
>> is always <= cluster_size (an int), and both slice and n_slices are
>> smaller than that.
> Well, what's the reason to use unsigned? :-)
> The type of the expression used to set slice_size2 simply is size_t.
I tend to choose the type of a variable based on what it's going to
hold, and use int (signed or not) whenever possible.
In this case a normal integer can certainly hold all possible values of
slice_size2. And unsigned because it's never going to be negative. It
could also be signed, it's not going to be any different in practice,
it's just more explicit.