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>
This commit is contained in:

committed by
Junio C Hamano

parent
23c32511b3
commit
66f892bb07
@ -42,7 +42,7 @@ static void test_block_read_write(void)
|
||||
block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size,
|
||||
header_off, hash_size(GIT_SHA1_FORMAT_ID));
|
||||
|
||||
rec.u.ref.refname = "";
|
||||
rec.u.ref.refname = (char *) "";
|
||||
rec.u.ref.value_type = REFTABLE_REF_DELETION;
|
||||
n = block_writer_add(&bw, &rec);
|
||||
EXPECT(n == REFTABLE_API_ERROR);
|
||||
|
Reference in New Issue
Block a user