On Fri, Mar 16, 2018 at 10:02 PM, Junio C Hamano <gits...@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy  <pclo...@gmail.com> writes:
>
>> Previous patches leave lots of holes and padding in this struct. This
>> patch reorders the members and shrinks the struct down to 80 bytes
>> (from 136 bytes, before any field shrinking is done) with 16 bits to
>> spare (and a couple more in in_pack_header_size when we really run out
>> of bits).
>
> Nice.
>
> I am wondering if we need some conditional code for 32-bit platform.
> For example, you have uint32_t field and do things like this:
>
>         static inline int oe_size_less_than(const struct object_entry *e,
>                                             unsigned long limit)
>         {
>                 if (e->size_valid)
>                         return e->size_ < limit;
>                 if (limit > maximum_unsigned_value_of_type(uint32_t))
>                         return 1;
>                 return oe_size(e) < limit;
>         }
>
> Do we and compilers do the right thing when your ulong is uint32_t?

Another good point. My 32-bit build does complain

In file included from builtin/pack-objects.c:20:0:
./pack-objects.h: In function ?oe_size_less_than?:
./pack-objects.h:282:12: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
  if (limit > maximum_unsigned_value_of_type(uint32_t))
            ^
-- 
Duy

Reply via email to