On Thu 01 Feb 2018 07:15:23 PM CET, Max Reitz <mre...@redhat.com> wrote: >>>> -static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t >>>> **table) >>>> +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. Berto