Skip to content

Commit 5fe9e1c

Browse files
peffgitster
authored andcommitted
ref-filter: mark unused callback parameters
The ref-filter code uses virtual functions to handle specific atoms, but many of the functions ignore some parameters: - most atom parsers do not need the ref_format itself, unless they are looking at centralized options like use_color, quote_style, etc. - meta-atom handlers like append_atom(), align_atom_handler(), etc, can't generate errors, so ignore their "err" parameter - likewise, the handlers for then/else/end do not even need to look at their atom_value, as the "if" handler put everything they need into the ref_formatting_state stack Since these functions all have to conform to virtual function interfaces, we can't just drop the unused parameters, but must mark them as UNUSED (to appease -Wunused-parameter). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2be1506 commit 5fe9e1c

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

ref-filter.c

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ static int refname_atom_parser_internal(struct refname_atom *atom, const char *a
282282
return 0;
283283
}
284284

285-
static int remote_ref_atom_parser(struct ref_format *format, struct used_atom *atom,
285+
static int remote_ref_atom_parser(struct ref_format *format UNUSED,
286+
struct used_atom *atom,
286287
const char *arg, struct strbuf *err)
287288
{
288289
struct string_list params = STRING_LIST_INIT_DUP;
@@ -329,7 +330,8 @@ static int remote_ref_atom_parser(struct ref_format *format, struct used_atom *a
329330
return 0;
330331
}
331332

332-
static int objecttype_atom_parser(struct ref_format *format, struct used_atom *atom,
333+
static int objecttype_atom_parser(struct ref_format *format UNUSED,
334+
struct used_atom *atom,
333335
const char *arg, struct strbuf *err)
334336
{
335337
if (arg)
@@ -341,7 +343,8 @@ static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a
341343
return 0;
342344
}
343345

344-
static int objectsize_atom_parser(struct ref_format *format, struct used_atom *atom,
346+
static int objectsize_atom_parser(struct ref_format *format UNUSED,
347+
struct used_atom *atom,
345348
const char *arg, struct strbuf *err)
346349
{
347350
if (!arg) {
@@ -361,7 +364,8 @@ static int objectsize_atom_parser(struct ref_format *format, struct used_atom *a
361364
return 0;
362365
}
363366

364-
static int deltabase_atom_parser(struct ref_format *format, struct used_atom *atom,
367+
static int deltabase_atom_parser(struct ref_format *format UNUSED,
368+
struct used_atom *atom,
365369
const char *arg, struct strbuf *err)
366370
{
367371
if (arg)
@@ -373,7 +377,8 @@ static int deltabase_atom_parser(struct ref_format *format, struct used_atom *at
373377
return 0;
374378
}
375379

376-
static int body_atom_parser(struct ref_format *format, struct used_atom *atom,
380+
static int body_atom_parser(struct ref_format *format UNUSED,
381+
struct used_atom *atom,
377382
const char *arg, struct strbuf *err)
378383
{
379384
if (arg)
@@ -382,7 +387,8 @@ static int body_atom_parser(struct ref_format *format, struct used_atom *atom,
382387
return 0;
383388
}
384389

385-
static int subject_atom_parser(struct ref_format *format, struct used_atom *atom,
390+
static int subject_atom_parser(struct ref_format *format UNUSED,
391+
struct used_atom *atom,
386392
const char *arg, struct strbuf *err)
387393
{
388394
if (!arg)
@@ -394,7 +400,8 @@ static int subject_atom_parser(struct ref_format *format, struct used_atom *atom
394400
return 0;
395401
}
396402

397-
static int trailers_atom_parser(struct ref_format *format, struct used_atom *atom,
403+
static int trailers_atom_parser(struct ref_format *format UNUSED,
404+
struct used_atom *atom,
398405
const char *arg, struct strbuf *err)
399406
{
400407
atom->u.contents.trailer_opts.no_divider = 1;
@@ -448,8 +455,9 @@ static int contents_atom_parser(struct ref_format *format, struct used_atom *ato
448455
return 0;
449456
}
450457

451-
static int raw_atom_parser(struct ref_format *format, struct used_atom *atom,
452-
const char *arg, struct strbuf *err)
458+
static int raw_atom_parser(struct ref_format *format UNUSED,
459+
struct used_atom *atom,
460+
const char *arg, struct strbuf *err)
453461
{
454462
if (!arg)
455463
atom->u.raw_data.option = RAW_BARE;
@@ -460,7 +468,8 @@ static int raw_atom_parser(struct ref_format *format, struct used_atom *atom,
460468
return 0;
461469
}
462470

463-
static int oid_atom_parser(struct ref_format *format, struct used_atom *atom,
471+
static int oid_atom_parser(struct ref_format *format UNUSED,
472+
struct used_atom *atom,
464473
const char *arg, struct strbuf *err)
465474
{
466475
if (!arg)
@@ -479,7 +488,8 @@ static int oid_atom_parser(struct ref_format *format, struct used_atom *atom,
479488
return 0;
480489
}
481490

482-
static int person_email_atom_parser(struct ref_format *format, struct used_atom *atom,
491+
static int person_email_atom_parser(struct ref_format *format UNUSED,
492+
struct used_atom *atom,
483493
const char *arg, struct strbuf *err)
484494
{
485495
if (!arg)
@@ -493,7 +503,8 @@ static int person_email_atom_parser(struct ref_format *format, struct used_atom
493503
return 0;
494504
}
495505

496-
static int refname_atom_parser(struct ref_format *format, struct used_atom *atom,
506+
static int refname_atom_parser(struct ref_format *format UNUSED,
507+
struct used_atom *atom,
497508
const char *arg, struct strbuf *err)
498509
{
499510
return refname_atom_parser_internal(&atom->u.refname, arg, atom->name, err);
@@ -510,7 +521,8 @@ static align_type parse_align_position(const char *s)
510521
return -1;
511522
}
512523

513-
static int align_atom_parser(struct ref_format *format, struct used_atom *atom,
524+
static int align_atom_parser(struct ref_format *format UNUSED,
525+
struct used_atom *atom,
514526
const char *arg, struct strbuf *err)
515527
{
516528
struct align *align = &atom->u.align;
@@ -562,7 +574,8 @@ static int align_atom_parser(struct ref_format *format, struct used_atom *atom,
562574
return 0;
563575
}
564576

565-
static int if_atom_parser(struct ref_format *format, struct used_atom *atom,
577+
static int if_atom_parser(struct ref_format *format UNUSED,
578+
struct used_atom *atom,
566579
const char *arg, struct strbuf *err)
567580
{
568581
if (!arg) {
@@ -577,7 +590,8 @@ static int if_atom_parser(struct ref_format *format, struct used_atom *atom,
577590
return 0;
578591
}
579592

580-
static int rest_atom_parser(struct ref_format *format, struct used_atom *atom,
593+
static int rest_atom_parser(struct ref_format *format,
594+
struct used_atom *atom UNUSED,
581595
const char *arg, struct strbuf *err)
582596
{
583597
if (arg)
@@ -586,7 +600,8 @@ static int rest_atom_parser(struct ref_format *format, struct used_atom *atom,
586600
return 0;
587601
}
588602

589-
static int head_atom_parser(struct ref_format *format, struct used_atom *atom,
603+
static int head_atom_parser(struct ref_format *format UNUSED,
604+
struct used_atom *atom,
590605
const char *arg, struct strbuf *err)
591606
{
592607
if (arg)
@@ -791,7 +806,7 @@ static void quote_formatting(struct strbuf *s, const char *str, ssize_t len, int
791806
}
792807

793808
static int append_atom(struct atom_value *v, struct ref_formatting_state *state,
794-
struct strbuf *unused_err)
809+
struct strbuf *err UNUSED)
795810
{
796811
/*
797812
* Quote formatting is only done when the stack has a single
@@ -841,7 +856,7 @@ static void end_align_handler(struct ref_formatting_stack **stack)
841856
}
842857

843858
static int align_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
844-
struct strbuf *unused_err)
859+
struct strbuf *err UNUSED)
845860
{
846861
struct ref_formatting_stack *new_stack;
847862

@@ -888,7 +903,7 @@ static void if_then_else_handler(struct ref_formatting_stack **stack)
888903
}
889904

890905
static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
891-
struct strbuf *unused_err)
906+
struct strbuf *err UNUSED)
892907
{
893908
struct ref_formatting_stack *new_stack;
894909
struct if_then_else *if_then_else = xcalloc(1,
@@ -915,7 +930,8 @@ static int is_empty(struct strbuf *buf)
915930
return cur == end;
916931
}
917932

918-
static int then_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
933+
static int then_atom_handler(struct atom_value *atomv UNUSED,
934+
struct ref_formatting_state *state,
919935
struct strbuf *err)
920936
{
921937
struct ref_formatting_stack *cur = state->stack;
@@ -952,7 +968,8 @@ static int then_atom_handler(struct atom_value *atomv, struct ref_formatting_sta
952968
return 0;
953969
}
954970

955-
static int else_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
971+
static int else_atom_handler(struct atom_value *atomv UNUSED,
972+
struct ref_formatting_state *state,
956973
struct strbuf *err)
957974
{
958975
struct ref_formatting_stack *prev = state->stack;
@@ -973,7 +990,8 @@ static int else_atom_handler(struct atom_value *atomv, struct ref_formatting_sta
973990
return 0;
974991
}
975992

976-
static int end_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
993+
static int end_atom_handler(struct atom_value *atomv UNUSED,
994+
struct ref_formatting_state *state,
977995
struct strbuf *err)
978996
{
979997
struct ref_formatting_stack *current = state->stack;

0 commit comments

Comments
 (0)