Re: [PATCH 1/4] repack: convert "names" util bitfield to array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 21, 2022 at 07:10:47PM -0400, Taylor Blau wrote:

> > +	struct generated_pack_data *data = xcalloc(1, sizeof(*data));
> 
> I'm nitpicking, but we could replace this with;
> 
>   struct generated_pack_data *data;
> 
>   CALLOC_ARRAY(data, 1);
> 
> so that we don't have to rely on calling sizeof(*data). But
> sizeof(*data) will always give us the right answer anyway, even if the
> name of data's type changed, so what you have is fine, too.

Yeah, I actually considered writing it that way, but it felt a bit silly
to use _ARRAY for something which is clearly meant to be a single item.
Grepping for "CALLOC_ARRAY([^)]*, 1)" does seem to turn up quite a few
hits, though, so maybe it is just me.

We could also introduce:

  #define CALLOC(x) CALLOC_ARRAY((x), 1)

but even if we think that is a good idea, it should not be in this
series.

It looks I may re-roll for the fname_old stuff in the other part of the
thread, so I'll take your suggestion.

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux