object-name: mark unused parameters in disambiguate callbacks

The object-name disambiguation code triggers a callback for each possible object id we find. This is really used for two purposes: - "hint" functions like disambiguate_commit_only report back on whether the value is usable - iterator functions like repo_for_each_abbrev() use it to collect and report matching names. Compiling with -Wunused-parameter generates several warnings, but they're distinct for each type. The "hint" functions never look at the void cb_data pointer; they only care whether the oid matches our hint. The iterator functions never look at the "struct repository" parameter; they're just reporting back the oids they see, and always return 0. So arguably these could be two separate interfaces: int (*hint)(struct repository *r, const struct object_id *oid); void (*iter)(const struct object_id *oid, void *cb_data); But doing so would complicate the disambiguation code, which now has to accept and call the two different types. Since we can easily squelch the compiler warnings by annotating the functions, let's just do that. 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:38 UTC 07ffb954b3421f78c5789477a540d400bbe647a2
1 file changed +7 -7
object-name.c
+7 -7
@@ -223,7 +223,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds,
223
224 static int disambiguate_commit_only(struct repository *r,
225 const struct object_id *oid,
226 - void *cb_data_unused)
226 + void *cb_data UNUSED)
227 {
228 int kind = oid_object_info(r, oid, NULL);
229 return kind == OBJ_COMMIT;
@@ -231,7 +231,7 @@ static int disambiguate_commit_only(struct repository *r,
231
232 static int disambiguate_committish_only(struct repository *r,
233 const struct object_id *oid,
234 - void *cb_data_unused)
234 + void *cb_data UNUSED)
235 {
236 struct object *obj;
237 int kind;
@@ -251,7 +251,7 @@ static int disambiguate_committish_only(struct repository *r,
251
252 static int disambiguate_tree_only(struct repository *r,
253 const struct object_id *oid,
254 - void *cb_data_unused)
254 + void *cb_data UNUSED)
255 {
256 int kind = oid_object_info(r, oid, NULL);
257 return kind == OBJ_TREE;
@@ -259,7 +259,7 @@ static int disambiguate_tree_only(struct repository *r,
259
260 static int disambiguate_treeish_only(struct repository *r,
261 const struct object_id *oid,
262 - void *cb_data_unused)
262 + void *cb_data UNUSED)
263 {
264 struct object *obj;
265 int kind;
@@ -279,7 +279,7 @@ static int disambiguate_treeish_only(struct repository *r,
279
280 static int disambiguate_blob_only(struct repository *r,
281 const struct object_id *oid,
282 - void *cb_data_unused)
282 + void *cb_data UNUSED)
283 {
284 int kind = oid_object_info(r, oid, NULL);
285 return kind == OBJ_BLOB;
@@ -473,7 +473,7 @@ static int collect_ambiguous(const struct object_id *oid, void *data)
473 return 0;
474 }
475
476 -static int repo_collect_ambiguous(struct repository *r,
476 +static int repo_collect_ambiguous(struct repository *r UNUSED,
477 const struct object_id *oid,
478 void *data)
479 {
@@ -665,7 +665,7 @@ static int extend_abbrev_len(const struct object_id *oid, void *cb_data)
665 return 0;
666 }
667
668 -static int repo_extend_abbrev_len(struct repository *r,
668 +static int repo_extend_abbrev_len(struct repository *r UNUSED,
669 const struct object_id *oid,
670 void *cb_data)
671 {