From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 08/14] fsck: mark unused parameters in various fsck callbacks
Date: Mon, 3 Jul 2023 02:44:18 -0400 [thread overview]
Message-ID: <20230703064418.GH3537614@coredump.intra.peff.net> (raw)
In-Reply-To: <20230703064347.GA3524892@coredump.intra.peff.net>
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 <peff@peff.net>
---
builtin/fsck.c | 10 +++++-----
builtin/index-pack.c | 3 ++-
builtin/mktag.c | 8 ++++----
builtin/unpack-objects.c | 3 ++-
fsck.c | 4 ++--
object-file.c | 10 +++++-----
6 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index fa26462337..9af71a4e03 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -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) {
@@ -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;
@@ -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;
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index c1250b070f..f6c2f0909d 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -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;
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 43e2766db4..d8e0b5afc0 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -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) {
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 1979532a9d..558b8485ba 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -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;
diff --git a/fsck.c b/fsck.c
index a219d6f2c0..feba5239a4 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1307,9 +1307,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) {
diff --git a/object-file.c b/object-file.c
index 8d87720dd5..68a2397e33 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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);
--
2.41.0.586.g3c0cc15bc7
next prev parent reply other threads:[~2023-07-03 6:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 6:43 [PATCH 0/14] more -Wunused-parameter annotations Jeff King
2023-07-03 6:43 ` [PATCH 01/14] test-ref-store: drop unimplemented reflog-expire command Jeff King
2023-07-03 6:44 ` [PATCH 02/14] do_for_each_ref_helper(): mark unused repository parameter Jeff King
2023-07-03 6:44 ` [PATCH 03/14] http: mark unused parameters in curl callbacks Jeff King
2023-07-03 6:44 ` [PATCH 04/14] http-push: mark unused parameter in xml callback Jeff King
2023-07-03 6:44 ` [PATCH 05/14] am: mark unused keep_cr parameters Jeff King
2023-07-03 6:44 ` [PATCH 06/14] count-objects: mark unused parameter in alternates callback Jeff King
2023-07-03 6:44 ` [PATCH 07/14] revisions: drop unused "opt" parameter in "tweak" callbacks Jeff King
2023-07-03 6:44 ` Jeff King [this message]
2023-07-03 6:44 ` [PATCH 09/14] merge-tree: mark unused parameter in traverse callback Jeff King
2023-07-03 6:44 ` [PATCH 10/14] replace: mark unused parameter in ref callback Jeff King
2023-07-03 6:44 ` [PATCH 11/14] replace: mark unused parameter in each_mergetag_fn callback Jeff King
2023-07-03 6:44 ` [PATCH 12/14] rev-parse: mark unused parameter in for_each_abbrev callback Jeff King
2023-07-03 6:44 ` [PATCH 13/14] tag: mark unused parameters in each_tag_name_fn callbacks Jeff King
2023-07-03 6:44 ` [PATCH 14/14] t/helper: mark unused callback void data parameters Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230703064418.GH3537614@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).