Skip to content

Commit 0b4e901

Browse files
peffgitster
authored andcommitted
fsck: mark unused parameters in various fsck callbacks
There are a few callback functions which are used with the fsck code, but it's natural that not all callbacks need all parameters. For reporting, even something as obvious as "the oid of the object which had a problem" is not always used, as some callers are only checking a single object in the first place. And for both reporting and walking, things like void data pointers and the fsck_options aren't always necessary. But since each such parameter is used by _some_ callback, we have to keep them in the interface. Mark the unused ones in specific callbacks to avoid triggering -Wunused-parameter. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc88afa commit 0b4e901

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

builtin/fsck.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ static int objerror(struct object *obj, const char *err)
9292
return -1;
9393
}
9494

95-
static int fsck_error_func(struct fsck_options *o,
95+
static int fsck_error_func(struct fsck_options *o UNUSED,
9696
const struct object_id *oid,
9797
enum object_type object_type,
9898
enum fsck_msg_type msg_type,
99-
enum fsck_msg_id msg_id,
99+
enum fsck_msg_id msg_id UNUSED,
100100
const char *message)
101101
{
102102
switch (msg_type) {
@@ -121,7 +121,7 @@ static int fsck_error_func(struct fsck_options *o,
121121
static struct object_array pending;
122122

123123
static int mark_object(struct object *obj, enum object_type type,
124-
void *data, struct fsck_options *options)
124+
void *data, struct fsck_options *options UNUSED)
125125
{
126126
struct object *parent = data;
127127

@@ -206,8 +206,8 @@ static int traverse_reachable(void)
206206
return !!result;
207207
}
208208

209-
static int mark_used(struct object *obj, enum object_type object_type,
210-
void *data, struct fsck_options *options)
209+
static int mark_used(struct object *obj, int type UNUSED,
210+
void *data UNUSED, struct fsck_options *options UNUSED)
211211
{
212212
if (!obj)
213213
return 1;

builtin/index-pack.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ static void cleanup_thread(void)
223223
}
224224

225225
static int mark_link(struct object *obj, enum object_type type,
226-
void *data, struct fsck_options *options)
226+
void *data UNUSED,
227+
struct fsck_options *options UNUSED)
227228
{
228229
if (!obj)
229230
return -1;

builtin/mktag.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ static int option_strict = 1;
1818

1919
static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;
2020

21-
static int mktag_fsck_error_func(struct fsck_options *o,
22-
const struct object_id *oid,
23-
enum object_type object_type,
21+
static int mktag_fsck_error_func(struct fsck_options *o UNUSED,
22+
const struct object_id *oid UNUSED,
23+
enum object_type object_type UNUSED,
2424
enum fsck_msg_type msg_type,
25-
enum fsck_msg_id msg_id,
25+
enum fsck_msg_id msg_id UNUSED,
2626
const char *message)
2727
{
2828
switch (msg_type) {

builtin/unpack-objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
214214
* Verify its reachability and validity recursively and write it out.
215215
*/
216216
static int check_object(struct object *obj, enum object_type type,
217-
void *data, struct fsck_options *options)
217+
void *data UNUSED,
218+
struct fsck_options *options UNUSED)
218219
{
219220
struct obj_buffer *obj_buf;
220221

fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,9 @@ int fsck_buffer(const struct object_id *oid, enum object_type type,
13101310

13111311
int fsck_error_function(struct fsck_options *o,
13121312
const struct object_id *oid,
1313-
enum object_type object_type,
1313+
enum object_type object_type UNUSED,
13141314
enum fsck_msg_type msg_type,
1315-
enum fsck_msg_id msg_id,
1315+
enum fsck_msg_id msg_id UNUSED,
13161316
const char *message)
13171317
{
13181318
if (msg_type == FSCK_WARN) {

object-file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,11 +2308,11 @@ int repo_has_object_file(struct repository *r,
23082308
* report the minimal fsck error here, and rely on the caller to
23092309
* give more context.
23102310
*/
2311-
static int hash_format_check_report(struct fsck_options *opts,
2312-
const struct object_id *oid,
2313-
enum object_type object_type,
2314-
enum fsck_msg_type msg_type,
2315-
enum fsck_msg_id msg_id,
2311+
static int hash_format_check_report(struct fsck_options *opts UNUSED,
2312+
const struct object_id *oid UNUSED,
2313+
enum object_type object_type UNUSED,
2314+
enum fsck_msg_type msg_type UNUSED,
2315+
enum fsck_msg_id msg_id UNUSED,
23162316
const char *message)
23172317
{
23182318
error(_("object fails fsck: %s"), message);

0 commit comments

Comments
 (0)