Skip to content

Commit

Permalink
fsck: mark unused parameters in various fsck callbacks
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
peff authored and gitster committed Jul 14, 2023
1 parent cc88afa commit 0b4e901
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
10 changes: 5 additions & 5 deletions builtin/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ static int objerror(struct object *obj, const char *err)
return -1;
}

static int fsck_error_func(struct fsck_options *o,
static int fsck_error_func(struct fsck_options *o UNUSED,
const struct object_id *oid,
enum object_type object_type,
enum fsck_msg_type msg_type,
enum fsck_msg_id msg_id,
enum fsck_msg_id msg_id UNUSED,
const char *message)
{
switch (msg_type) {
Expand All @@ -121,7 +121,7 @@ static int fsck_error_func(struct fsck_options *o,
static struct object_array pending;

static int mark_object(struct object *obj, enum object_type type,
void *data, struct fsck_options *options)
void *data, struct fsck_options *options UNUSED)
{
struct object *parent = data;

Expand Down Expand Up @@ -206,8 +206,8 @@ static int traverse_reachable(void)
return !!result;
}

static int mark_used(struct object *obj, enum object_type object_type,
void *data, struct fsck_options *options)
static int mark_used(struct object *obj, int type UNUSED,
void *data UNUSED, struct fsck_options *options UNUSED)
{
if (!obj)
return 1;
Expand Down
3 changes: 2 additions & 1 deletion builtin/index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ static void cleanup_thread(void)
}

static int mark_link(struct object *obj, enum object_type type,
void *data, struct fsck_options *options)
void *data UNUSED,
struct fsck_options *options UNUSED)
{
if (!obj)
return -1;
Expand Down
8 changes: 4 additions & 4 deletions builtin/mktag.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ static int option_strict = 1;

static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;

static int mktag_fsck_error_func(struct fsck_options *o,
const struct object_id *oid,
enum object_type object_type,
static int mktag_fsck_error_func(struct fsck_options *o UNUSED,
const struct object_id *oid UNUSED,
enum object_type object_type UNUSED,
enum fsck_msg_type msg_type,
enum fsck_msg_id msg_id,
enum fsck_msg_id msg_id UNUSED,
const char *message)
{
switch (msg_type) {
Expand Down
3 changes: 2 additions & 1 deletion builtin/unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf)
* Verify its reachability and validity recursively and write it out.
*/
static int check_object(struct object *obj, enum object_type type,
void *data, struct fsck_options *options)
void *data UNUSED,
struct fsck_options *options UNUSED)
{
struct obj_buffer *obj_buf;

Expand Down
4 changes: 2 additions & 2 deletions fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,9 @@ int fsck_buffer(const struct object_id *oid, enum object_type type,

int fsck_error_function(struct fsck_options *o,
const struct object_id *oid,
enum object_type object_type,
enum object_type object_type UNUSED,
enum fsck_msg_type msg_type,
enum fsck_msg_id msg_id,
enum fsck_msg_id msg_id UNUSED,
const char *message)
{
if (msg_type == FSCK_WARN) {
Expand Down
10 changes: 5 additions & 5 deletions object-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2308,11 +2308,11 @@ int repo_has_object_file(struct repository *r,
* report the minimal fsck error here, and rely on the caller to
* give more context.
*/
static int hash_format_check_report(struct fsck_options *opts,
const struct object_id *oid,
enum object_type object_type,
enum fsck_msg_type msg_type,
enum fsck_msg_id msg_id,
static int hash_format_check_report(struct fsck_options *opts UNUSED,
const struct object_id *oid UNUSED,
enum object_type object_type UNUSED,
enum fsck_msg_type msg_type UNUSED,
enum fsck_msg_id msg_id UNUSED,
const char *message)
{
error(_("object fails fsck: %s"), message);
Expand Down

0 comments on commit 0b4e901

Please sign in to comment.