reftable/basics: introduce `REFTABLE_UNUSED` annotation

Introduce the `REFTABLE_UNUSED` annotation and replace all existing
users of `UNUSED` in the reftable library to use the new macro instead.

Note that we unconditionally define `MAYBE_UNUSED` in the exact same
way, so doing so unconditionally for `REFTABLE_UNUSED` should be fine,
too.

Suggested-by: Toon Claes <toon@iotcl.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2025-02-18 10:20:50 +01:00 committed by Junio C Hamano
parent f8ed12dec4
commit f93b2a0424
5 changed files with 24 additions and 22 deletions

View File

@ -16,6 +16,8 @@ https://developers.google.com/open-source/licenses/bsd
#include "system.h"
#include "reftable-basics.h"

#define REFTABLE_UNUSED __attribute__((__unused__))

struct reftable_buf {
size_t alloc;
size_t len;

View File

@ -13,14 +13,14 @@ https://developers.google.com/open-source/licenses/bsd
#include "reftable-blocksource.h"
#include "reftable-error.h"

static void reftable_buf_return_block(void *b UNUSED, struct reftable_block *dest)
static void reftable_buf_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest)
{
if (dest->len)
memset(dest->data, 0xff, dest->len);
reftable_free(dest->data);
}

static void reftable_buf_close(void *b UNUSED)
static void reftable_buf_close(void *b REFTABLE_UNUSED)
{
}

@ -67,7 +67,7 @@ static uint64_t file_size(void *b)
return ((struct file_block_source *)b)->size;
}

static void file_return_block(void *b UNUSED, struct reftable_block *dest UNUSED)
static void file_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest REFTABLE_UNUSED)
{
}


View File

@ -25,17 +25,17 @@ int iterator_next(struct reftable_iterator *it, struct reftable_record *rec)
return it->ops->next(it->iter_arg, rec);
}

static int empty_iterator_seek(void *arg UNUSED, struct reftable_record *want UNUSED)
static int empty_iterator_seek(void *arg REFTABLE_UNUSED, struct reftable_record *want REFTABLE_UNUSED)
{
return 0;
}

static int empty_iterator_next(void *arg UNUSED, struct reftable_record *rec UNUSED)
static int empty_iterator_next(void *arg REFTABLE_UNUSED, struct reftable_record *rec REFTABLE_UNUSED)
{
return 1;
}

static void empty_iterator_close(void *arg UNUSED)
static void empty_iterator_close(void *arg REFTABLE_UNUSED)
{
}

@ -143,8 +143,8 @@ static int indexed_table_ref_iter_next_block(struct indexed_table_ref_iter *it)
return 0;
}

static int indexed_table_ref_iter_seek(void *p UNUSED,
struct reftable_record *want UNUSED)
static int indexed_table_ref_iter_seek(void *p REFTABLE_UNUSED,
struct reftable_record *want REFTABLE_UNUSED)
{
return REFTABLE_API_ERROR;
}

View File

@ -490,7 +490,7 @@ static void reftable_obj_record_release(void *rec)
}

static int reftable_obj_record_copy_from(void *rec, const void *src_rec,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
struct reftable_obj_record *obj = rec;
const struct reftable_obj_record *src = src_rec;
@ -528,7 +528,7 @@ static uint8_t reftable_obj_record_val_type(const void *rec)
}

static int reftable_obj_record_encode(const void *rec, struct string_view s,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
const struct reftable_obj_record *r = rec;
struct string_view start = s;
@ -563,8 +563,8 @@ static int reftable_obj_record_encode(const void *rec, struct string_view s,

static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
uint8_t val_type, struct string_view in,
uint32_t hash_size UNUSED,
struct reftable_buf *scratch UNUSED)
uint32_t hash_size REFTABLE_UNUSED,
struct reftable_buf *scratch REFTABLE_UNUSED)
{
struct string_view start = in;
struct reftable_obj_record *r = rec;
@ -618,13 +618,13 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
return start.len - in.len;
}

static int not_a_deletion(const void *p UNUSED)
static int not_a_deletion(const void *p REFTABLE_UNUSED)
{
return 0;
}

static int reftable_obj_record_equal_void(const void *a, const void *b,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
struct reftable_obj_record *ra = (struct reftable_obj_record *) a;
struct reftable_obj_record *rb = (struct reftable_obj_record *) b;
@ -1054,7 +1054,7 @@ static int reftable_index_record_key(const void *r, struct reftable_buf *dest)
}

static int reftable_index_record_copy_from(void *rec, const void *src_rec,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
struct reftable_index_record *dst = rec;
const struct reftable_index_record *src = src_rec;
@ -1075,13 +1075,13 @@ static void reftable_index_record_release(void *rec)
reftable_buf_release(&idx->last_key);
}

static uint8_t reftable_index_record_val_type(const void *rec UNUSED)
static uint8_t reftable_index_record_val_type(const void *rec REFTABLE_UNUSED)
{
return 0;
}

static int reftable_index_record_encode(const void *rec, struct string_view out,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
const struct reftable_index_record *r =
(const struct reftable_index_record *)rec;
@ -1097,10 +1097,10 @@ static int reftable_index_record_encode(const void *rec, struct string_view out,
}

static int reftable_index_record_decode(void *rec, struct reftable_buf key,
uint8_t val_type UNUSED,
uint8_t val_type REFTABLE_UNUSED,
struct string_view in,
uint32_t hash_size UNUSED,
struct reftable_buf *scratch UNUSED)
uint32_t hash_size REFTABLE_UNUSED,
struct reftable_buf *scratch REFTABLE_UNUSED)
{
struct string_view start = in;
struct reftable_index_record *r = rec;
@ -1120,7 +1120,7 @@ static int reftable_index_record_decode(void *rec, struct reftable_buf key,
}

static int reftable_index_record_equal(const void *a, const void *b,
uint32_t hash_size UNUSED)
uint32_t hash_size REFTABLE_UNUSED)
{
struct reftable_index_record *ia = (struct reftable_index_record *) a;
struct reftable_index_record *ib = (struct reftable_index_record *) b;

View File

@ -649,7 +649,7 @@ static void write_object_record(void *void_arg, void *key)
done:;
}

static void object_record_free(void *void_arg UNUSED, void *key)
static void object_record_free(void *void_arg REFTABLE_UNUSED, void *key)
{
struct obj_index_tree_node *entry = key;