for_each_object: mark unused callback parameters

The for_each_{loose,packed}_object interface uses callback functions, but not every callback needs all of the parameters. Mark the unused ones to satisfy -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 be252d3349f1a5fdf7aaf53390f3ce555b5de9d9
14 files changed +56 -45
builtin/cat-file.c
+4 -4
@@ -559,7 +559,7 @@ static int batch_object_cb(const struct object_id *oid, void *vdata)
559 }
560
561 static int collect_loose_object(const struct object_id *oid,
562 - const char *path,
562 + const char *path UNUSED,
563 void *data)
564 {
565 oid_array_append(data, oid);
@@ -567,8 +567,8 @@ static int collect_loose_object(const struct object_id *oid,
567 }
568
569 static int collect_packed_object(const struct object_id *oid,
570 - struct packed_git *pack,
571 - uint32_t pos,
570 + struct packed_git *pack UNUSED,
571 + uint32_t pos UNUSED,
572 void *data)
573 {
574 oid_array_append(data, oid);
@@ -591,7 +591,7 @@ static int batch_unordered_object(const struct object_id *oid,
591 }
592
593 static int batch_unordered_loose(const struct object_id *oid,
594 - const char *path,
594 + const char *path UNUSED,
595 void *data)
596 {
597 return batch_unordered_object(oid, NULL, 0, data);
builtin/count-objects.c
+4 -2
@@ -57,7 +57,8 @@ static void loose_garbage(const char *path)
57 report_garbage(PACKDIR_FILE_GARBAGE, path);
58 }
59
60 -static int count_loose(const struct object_id *oid, const char *path, void *data)
60 +static int count_loose(const struct object_id *oid, const char *path,
61 + void *data UNUSED)
62 {
63 struct stat st;
64
@@ -72,7 +73,8 @@ static int count_loose(const struct object_id *oid, const char *path, void *data
73 return 0;
74 }
75
75 -static int count_cruft(const char *basename, const char *path, void *data)
76 +static int count_cruft(const char *basename UNUSED, const char *path,
77 + void *data UNUSED)
78 {
79 loose_garbage(path);
80 return 0;
builtin/fsck.c
+13 -12
@@ -233,17 +233,17 @@ static void mark_unreachable_referents(const struct object_id *oid)
233 }
234
235 static int mark_loose_unreachable_referents(const struct object_id *oid,
236 - const char *path,
237 - void *data)
236 + const char *path UNUSED,
237 + void *data UNUSED)
238 {
239 mark_unreachable_referents(oid);
240 return 0;
241 }
242
243 static int mark_packed_unreachable_referents(const struct object_id *oid,
244 - struct packed_git *pack,
245 - uint32_t pos,
246 - void *data)
244 + struct packed_git *pack UNUSED,
245 + uint32_t pos UNUSED,
246 + void *data UNUSED)
247 {
248 mark_unreachable_referents(oid);
249 return 0;
@@ -661,14 +661,15 @@ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
661 return 0; /* keep checking other objects, even if we saw an error */
662 }
663
664 -static int fsck_cruft(const char *basename, const char *path, void *data)
664 +static int fsck_cruft(const char *basename, const char *path,
665 + void *data UNUSED)
666 {
667 if (!starts_with(basename, "tmp_obj_"))
668 fprintf_ln(stderr, _("bad sha1 file: %s"), path);
669 return 0;
670 }
671
671 -static int fsck_subdir(unsigned int nr, const char *path, void *data)
672 +static int fsck_subdir(unsigned int nr, const char *path UNUSED, void *data)
673 {
674 struct for_each_loose_cb *cb_data = data;
675 struct progress *progress = cb_data->progress;
@@ -803,17 +804,17 @@ static void mark_object_for_connectivity(const struct object_id *oid)
804 }
805
806 static int mark_loose_for_connectivity(const struct object_id *oid,
806 - const char *path,
807 - void *data)
807 + const char *path UNUSED,
808 + void *data UNUSED)
809 {
810 mark_object_for_connectivity(oid);
811 return 0;
812 }
813
814 static int mark_packed_for_connectivity(const struct object_id *oid,
814 - struct packed_git *pack,
815 - uint32_t pos,
816 - void *data)
815 + struct packed_git *pack UNUSED,
816 + uint32_t pos UNUSED,
817 + void *data UNUSED)
818 {
819 mark_object_for_connectivity(oid);
820 return 0;
builtin/gc.c
+7 -7
@@ -976,9 +976,9 @@ struct write_loose_object_data {
976
977 static int loose_object_auto_limit = 100;
978
979 -static int loose_object_count(const struct object_id *oid,
980 - const char *path,
981 - void *data)
979 +static int loose_object_count(const struct object_id *oid UNUSED,
980 + const char *path UNUSED,
981 + void *data)
982 {
983 int *count = (int*)data;
984 if (++(*count) >= loose_object_auto_limit)
@@ -1003,15 +1003,15 @@ static int loose_object_auto_condition(void)
1003 NULL, NULL, &count);
1004 }
1005
1006 -static int bail_on_loose(const struct object_id *oid,
1007 - const char *path,
1008 - void *data)
1006 +static int bail_on_loose(const struct object_id *oid UNUSED,
1007 + const char *path UNUSED,
1008 + void *data UNUSED)
1009 {
1010 return 1;
1011 }
1012
1013 static int write_loose_object_to_stdin(const struct object_id *oid,
1014 - const char *path,
1014 + const char *path UNUSED,
1015 void *data)
1016 {
1017 struct write_loose_object_data *d = (struct write_loose_object_data *)data;
builtin/pack-objects.c
+8 -7
@@ -3260,13 +3260,14 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3260 return 0;
3261 }
3262
3263 -static void show_commit_pack_hint(struct commit *commit, void *_data)
3263 +static void show_commit_pack_hint(struct commit *commit UNUSED,
3264 + void *data UNUSED)
3265 {
3266 /* nothing to do; commits don't have a namehash */
3267 }
3268
3269 static void show_object_pack_hint(struct object *object, const char *name,
3269 - void *_data)
3270 + void *data UNUSED)
3271 {
3272 struct object_entry *oe = packlist_find(&to_pack, &object->oid);
3273 if (!oe)
@@ -3762,7 +3763,7 @@ static void show_edge(struct commit *commit)
3763 static int add_object_in_unpacked_pack(const struct object_id *oid,
3764 struct packed_git *pack,
3765 uint32_t pos,
3765 - void *_data)
3766 + void *data UNUSED)
3767 {
3768 if (cruft) {
3769 off_t offset;
@@ -3796,7 +3797,7 @@ static void add_objects_in_unpacked_packs(void)
3797 }
3798
3799 static int add_loose_object(const struct object_id *oid, const char *path,
3799 - void *data)
3800 + void *data UNUSED)
3801 {
3802 enum object_type type = oid_object_info(the_repository, oid, NULL);
3803
@@ -3947,13 +3948,13 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
3948 }
3949
3950 static void record_recent_object(struct object *obj,
3950 - const char *name,
3951 - void *data)
3951 + const char *name UNUSED,
3952 + void *data UNUSED)
3953 {
3954 oid_array_append(&recent_objects, &obj->oid);
3955 }
3956
3956 -static void record_recent_commit(struct commit *commit, void *data)
3957 +static void record_recent_commit(struct commit *commit, void *data UNUSED)
3958 {
3959 oid_array_append(&recent_objects, &commit->object.oid);
3960 }
builtin/prune.c
+4 -2
@@ -98,7 +98,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath,
98 return 0;
99 }
100
101 -static int prune_cruft(const char *basename, const char *path, void *data)
101 +static int prune_cruft(const char *basename, const char *path,
102 + void *data UNUSED)
103 {
104 if (starts_with(basename, "tmp_obj_"))
105 prune_tmp_file(path);
@@ -107,7 +108,8 @@ static int prune_cruft(const char *basename, const char *path, void *data)
108 return 0;
109 }
110
110 -static int prune_subdir(unsigned int nr, const char *path, void *data)
111 +static int prune_subdir(unsigned int nr UNUSED, const char *path,
112 + void *data UNUSED)
113 {
114 if (!show_only)
115 rmdir(path);
builtin/repack.c
+3 -2
@@ -182,8 +182,9 @@ static void prepare_pack_objects(struct child_process *cmd,
182 * Write oid to the given struct child_process's stdin, starting it first if
183 * necessary.
184 */
185 -static int write_oid(const struct object_id *oid, struct packed_git *pack,
186 - uint32_t pos, void *data)
185 +static int write_oid(const struct object_id *oid,
186 + struct packed_git *pack UNUSED,
187 + uint32_t pos UNUSED, void *data)
188 {
189 struct child_process *cmd = data;
190
builtin/rev-list.c
+2 -1
@@ -257,7 +257,8 @@ static inline void finish_object__ma(struct object *obj)
257 }
258 }
259
260 -static int finish_object(struct object *obj, const char *name, void *cb_data)
260 +static int finish_object(struct object *obj, const char *name UNUSED,
261 + void *cb_data)
262 {
263 struct rev_list_info *info = cb_data;
264 if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
diagnose.c
+2 -1
@@ -43,7 +43,8 @@ int option_parse_diagnose(const struct option *opt, const char *arg, int unset)
43 return error(_("invalid --%s value '%s'"), opt->long_name, arg);
44 }
45
46 -static void dir_file_stats_objects(const char *full_path, size_t full_path_len,
46 +static void dir_file_stats_objects(const char *full_path,
47 + size_t full_path_len UNUSED,
48 const char *file_name, void *data)
49 {
50 struct strbuf *buf = data;
midx.c
+1 -1
@@ -1607,7 +1607,7 @@ struct clear_midx_data {
1607 const char *ext;
1608 };
1609
1610 -static void clear_midx_file_ext(const char *full_path, size_t full_path_len,
1610 +static void clear_midx_file_ext(const char *full_path, size_t full_path_len UNUSED,
1611 const char *file_name, void *_data)
1612 {
1613 struct clear_midx_data *data = _data;
object-file.c
+2 -1
@@ -2644,7 +2644,8 @@ int for_each_loose_object(each_loose_object_fn cb, void *data,
2644 return 0;
2645 }
2646
2647 -static int append_loose_object(const struct object_id *oid, const char *path,
2647 +static int append_loose_object(const struct object_id *oid,
2648 + const char *path UNUSED,
2649 void *data)
2650 {
2651 oidtree_insert(data, oid);
packfile.c
+2 -2
@@ -2204,8 +2204,8 @@ int for_each_packed_object(each_packed_object_fn cb, void *data,
2204 }
2205
2206 static int add_promisor_object(const struct object_id *oid,
2207 - struct packed_git *pack,
2208 - uint32_t pos,
2207 + struct packed_git *pack UNUSED,
2208 + uint32_t pos UNUSED,
2209 void *set_)
2210 {
2211 struct oidset *set = set_;
reachable.c
+2 -1
@@ -154,7 +154,8 @@ static int add_recent_loose(const struct object_id *oid,
154 }
155
156 static int add_recent_packed(const struct object_id *oid,
157 - struct packed_git *p, uint32_t pos,
157 + struct packed_git *p,
158 + uint32_t pos,
159 void *data)
160 {
161 struct object *obj;
revision.c
+2 -2
@@ -3440,8 +3440,8 @@ void reset_revision_walk(void)
3440 }
3441
3442 static int mark_uninteresting(const struct object_id *oid,
3443 - struct packed_git *pack,
3444 - uint32_t pos,
3443 + struct packed_git *pack UNUSED,
3444 + uint32_t pos UNUSED,
3445 void *cb)
3446 {
3447 struct rev_info *revs = cb;