Skip to content

Commit f93b2a0

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f8ed12d commit f93b2a0

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed

reftable/basics.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ license that can be found in the LICENSE file or at
1616
#include "system.h"
1717
#include "reftable-basics.h"
1818

19+
#define REFTABLE_UNUSED __attribute__((__unused__))
20+
1921
struct reftable_buf {
2022
size_t alloc;
2123
size_t len;

reftable/blocksource.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ license that can be found in the LICENSE file or at
1313
#include "reftable-blocksource.h"
1414
#include "reftable-error.h"
1515

16-
static void reftable_buf_return_block(void *b UNUSED, struct reftable_block *dest)
16+
static void reftable_buf_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest)
1717
{
1818
if (dest->len)
1919
memset(dest->data, 0xff, dest->len);
2020
reftable_free(dest->data);
2121
}
2222

23-
static void reftable_buf_close(void *b UNUSED)
23+
static void reftable_buf_close(void *b REFTABLE_UNUSED)
2424
{
2525
}
2626

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

70-
static void file_return_block(void *b UNUSED, struct reftable_block *dest UNUSED)
70+
static void file_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest REFTABLE_UNUSED)
7171
{
7272
}
7373

reftable/iter.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ int iterator_next(struct reftable_iterator *it, struct reftable_record *rec)
2525
return it->ops->next(it->iter_arg, rec);
2626
}
2727

28-
static int empty_iterator_seek(void *arg UNUSED, struct reftable_record *want UNUSED)
28+
static int empty_iterator_seek(void *arg REFTABLE_UNUSED, struct reftable_record *want REFTABLE_UNUSED)
2929
{
3030
return 0;
3131
}
3232

33-
static int empty_iterator_next(void *arg UNUSED, struct reftable_record *rec UNUSED)
33+
static int empty_iterator_next(void *arg REFTABLE_UNUSED, struct reftable_record *rec REFTABLE_UNUSED)
3434
{
3535
return 1;
3636
}
3737

38-
static void empty_iterator_close(void *arg UNUSED)
38+
static void empty_iterator_close(void *arg REFTABLE_UNUSED)
3939
{
4040
}
4141

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

146-
static int indexed_table_ref_iter_seek(void *p UNUSED,
147-
struct reftable_record *want UNUSED)
146+
static int indexed_table_ref_iter_seek(void *p REFTABLE_UNUSED,
147+
struct reftable_record *want REFTABLE_UNUSED)
148148
{
149149
return REFTABLE_API_ERROR;
150150
}

reftable/record.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static void reftable_obj_record_release(void *rec)
490490
}
491491

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

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

564564
static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
565565
uint8_t val_type, struct string_view in,
566-
uint32_t hash_size UNUSED,
567-
struct reftable_buf *scratch UNUSED)
566+
uint32_t hash_size REFTABLE_UNUSED,
567+
struct reftable_buf *scratch REFTABLE_UNUSED)
568568
{
569569
struct string_view start = in;
570570
struct reftable_obj_record *r = rec;
@@ -618,13 +618,13 @@ static int reftable_obj_record_decode(void *rec, struct reftable_buf key,
618618
return start.len - in.len;
619619
}
620620

621-
static int not_a_deletion(const void *p UNUSED)
621+
static int not_a_deletion(const void *p REFTABLE_UNUSED)
622622
{
623623
return 0;
624624
}
625625

626626
static int reftable_obj_record_equal_void(const void *a, const void *b,
627-
uint32_t hash_size UNUSED)
627+
uint32_t hash_size REFTABLE_UNUSED)
628628
{
629629
struct reftable_obj_record *ra = (struct reftable_obj_record *) a;
630630
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)
10541054
}
10551055

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

1078-
static uint8_t reftable_index_record_val_type(const void *rec UNUSED)
1078+
static uint8_t reftable_index_record_val_type(const void *rec REFTABLE_UNUSED)
10791079
{
10801080
return 0;
10811081
}
10821082

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

10991099
static int reftable_index_record_decode(void *rec, struct reftable_buf key,
1100-
uint8_t val_type UNUSED,
1100+
uint8_t val_type REFTABLE_UNUSED,
11011101
struct string_view in,
1102-
uint32_t hash_size UNUSED,
1103-
struct reftable_buf *scratch UNUSED)
1102+
uint32_t hash_size REFTABLE_UNUSED,
1103+
struct reftable_buf *scratch REFTABLE_UNUSED)
11041104
{
11051105
struct string_view start = in;
11061106
struct reftable_index_record *r = rec;
@@ -1120,7 +1120,7 @@ static int reftable_index_record_decode(void *rec, struct reftable_buf key,
11201120
}
11211121

11221122
static int reftable_index_record_equal(const void *a, const void *b,
1123-
uint32_t hash_size UNUSED)
1123+
uint32_t hash_size REFTABLE_UNUSED)
11241124
{
11251125
struct reftable_index_record *ia = (struct reftable_index_record *) a;
11261126
struct reftable_index_record *ib = (struct reftable_index_record *) b;

reftable/writer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static void write_object_record(void *void_arg, void *key)
649649
done:;
650650
}
651651

652-
static void object_record_free(void *void_arg UNUSED, void *key)
652+
static void object_record_free(void *void_arg REFTABLE_UNUSED, void *key)
653653
{
654654
struct obj_index_tree_node *entry = key;
655655

0 commit comments

Comments
 (0)