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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 24, 2023 at 01:39 UTC 5fe9e1ce2f7e0be5ea817f2e4ae2c7edecf771c0
1 file changed +40 -22
ref-filter.c
+40 -22
@@ -282,7 +282,8 @@ static int refname_atom_parser_internal(struct refname_atom *atom, const char *a
282 return 0;
283 }
284
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,
287 const char *arg, struct strbuf *err)
288 {
289 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
330 return 0;
331 }
332
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,
335 const char *arg, struct strbuf *err)
336 {
337 if (arg)
@@ -341,7 +343,8 @@ static int objecttype_atom_parser(struct ref_format *format, struct used_atom *a
343 return 0;
344 }
345
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,
348 const char *arg, struct strbuf *err)
349 {
350 if (!arg) {
@@ -361,7 +364,8 @@ static int objectsize_atom_parser(struct ref_format *format, struct used_atom *a
364 return 0;
365 }
366
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,
369 const char *arg, struct strbuf *err)
370 {
371 if (arg)
@@ -373,7 +377,8 @@ static int deltabase_atom_parser(struct ref_format *format, struct used_atom *at
377 return 0;
378 }
379
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,
382 const char *arg, struct strbuf *err)
383 {
384 if (arg)
@@ -382,7 +387,8 @@ static int body_atom_parser(struct ref_format *format, struct used_atom *atom,
387 return 0;
388 }
389
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,
392 const char *arg, struct strbuf *err)
393 {
394 if (!arg)
@@ -394,7 +400,8 @@ static int subject_atom_parser(struct ref_format *format, struct used_atom *atom
400 return 0;
401 }
402
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,
405 const char *arg, struct strbuf *err)
406 {
407 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
455 return 0;
456 }
457
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)
461 {
462 if (!arg)
463 atom->u.raw_data.option = RAW_BARE;
@@ -460,7 +468,8 @@ static int raw_atom_parser(struct ref_format *format, struct used_atom *atom,
468 return 0;
469 }
470
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,
473 const char *arg, struct strbuf *err)
474 {
475 if (!arg)
@@ -479,7 +488,8 @@ static int oid_atom_parser(struct ref_format *format, struct used_atom *atom,
488 return 0;
489 }
490
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,
493 const char *arg, struct strbuf *err)
494 {
495 if (!arg)
@@ -493,7 +503,8 @@ static int person_email_atom_parser(struct ref_format *format, struct used_atom
503 return 0;
504 }
505
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,
508 const char *arg, struct strbuf *err)
509 {
510 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)
521 return -1;
522 }
523
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,
526 const char *arg, struct strbuf *err)
527 {
528 struct align *align = &atom->u.align;
@@ -562,7 +574,8 @@ static int align_atom_parser(struct ref_format *format, struct used_atom *atom,
574 return 0;
575 }
576
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,
579 const char *arg, struct strbuf *err)
580 {
581 if (!arg) {
@@ -577,7 +590,8 @@ static int if_atom_parser(struct ref_format *format, struct used_atom *atom,
590 return 0;
591 }
592
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,
595 const char *arg, struct strbuf *err)
596 {
597 if (arg)
@@ -586,7 +600,8 @@ static int rest_atom_parser(struct ref_format *format, struct used_atom *atom,
600 return 0;
601 }
602
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,
605 const char *arg, struct strbuf *err)
606 {
607 if (arg)
@@ -791,7 +806,7 @@ static void quote_formatting(struct strbuf *s, const char *str, ssize_t len, int
806 }
807
808 static int append_atom(struct atom_value *v, struct ref_formatting_state *state,
794 - struct strbuf *unused_err)
809 + struct strbuf *err UNUSED)
810 {
811 /*
812 * 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)
856 }
857
858 static int align_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
844 - struct strbuf *unused_err)
859 + struct strbuf *err UNUSED)
860 {
861 struct ref_formatting_stack *new_stack;
862
@@ -888,7 +903,7 @@ static void if_then_else_handler(struct ref_formatting_stack **stack)
903 }
904
905 static int if_atom_handler(struct atom_value *atomv, struct ref_formatting_state *state,
891 - struct strbuf *unused_err)
906 + struct strbuf *err UNUSED)
907 {
908 struct ref_formatting_stack *new_stack;
909 struct if_then_else *if_then_else = xcalloc(1,
@@ -915,7 +930,8 @@ static int is_empty(struct strbuf *buf)
930 return cur == end;
931 }
932
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,
935 struct strbuf *err)
936 {
937 struct ref_formatting_stack *cur = state->stack;
@@ -952,7 +968,8 @@ static int then_atom_handler(struct atom_value *atomv, struct ref_formatting_sta
968 return 0;
969 }
970
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,
973 struct strbuf *err)
974 {
975 struct ref_formatting_stack *prev = state->stack;
@@ -973,7 +990,8 @@ static int else_atom_handler(struct atom_value *atomv, struct ref_formatting_sta
990 return 0;
991 }
992
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,
995 struct strbuf *err)
996 {
997 struct ref_formatting_stack *current = state->stack;