]> git.ipfire.org Git - thirdparty/git.git/commit
reftable: cast away constness when assigning constants to records
authorPatrick Steinhardt <ps@pks.im>
Fri, 7 Jun 2024 06:37:52 +0000 (08:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Jun 2024 17:30:49 +0000 (10:30 -0700)
commit66f892bb075f19bed784b86c7850a89c9a865aca
tree8549dfeb0440f64135efcb15528fe105f7b18240
parent23c32511b31f2123fd194ba3a89c758ba3e55143
reftable: cast away constness when assigning constants to records

The reftable records are used in multiple ways throughout the reftable
library. In many of those cases they merely act as input to a function
without getting modified by it at all. Most importantly, this happens
when writing records and when querying for records.

We rely on this in our tests and thus assign string constants to those
fields, which is about to generate warnings as those fields are of type
`char *`. While we could go through the process and instead allocate
those strings in all of our tests, this feels quite unnecessary.

Instead, add casts to `char *` for all of those strings. As this is part
of our tests, this also nicely serves as a demonstration that nothing
writes or frees those string constants, which would otherwise lead to
segfaults.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/block_test.c
reftable/merged_test.c
reftable/readwrite_test.c
reftable/stack_test.c