Re: [PATCH v3 2/6] pack-bitmap-write.c: write lookup table extension

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

 



On Mon, 4 Jul 2022 at 10:48, Abhradeep Chakraborty via GitGitGadget
<gitgitgadget@xxxxxxxxx> wrote:
>
> +static int table_cmp(const void *_va, const void *_vb, void *_data)
> +{
> +       uint32_t *commit_positions = _data;
> +       uint32_t a = commit_positions[*(uint32_t *)_va];
> +       uint32_t b = commit_positions[*(uint32_t *)_vb];

This casting and dereferencing are ok because ...

> +static void write_lookup_table(struct hashfile *f,
> +                              struct pack_idx_entry **index,
> +                              uint32_t index_nr,
> +                              off_t *offsets)
> +{
> +       uint32_t i;
> +       uint32_t *table, *table_inv, *commit_positions;
> +
> +       ALLOC_ARRAY(table, writer.selected_nr);
> +       ALLOC_ARRAY(table_inv, writer.selected_nr);
> +       ALLOC_ARRAY(commit_positions, writer.selected_nr);

... `table` is where `_va` and `_vb` will be pointing into.

> +       QSORT_S(table, writer.selected_nr, table_cmp, commit_positions);

I started looking at this casting because of something similar in
"pack-bitmap: prepare to read lookup table extension". I'm pointing out
this instance just to say that it looks ok to me.


Martin



[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