From: Patrick Steinhardt Date: Thu, 20 Mar 2025 09:18:00 GMT Subject: Re: [PATCH 1/8] pretty: tighten function signature to not take `void *` Message-ID: In-Reply-To: <192fc78dd869f28cb6ae91f3a26a05eb6b6a4bbf.1742367347.git.martin.agren@gmail.com> On Wed, Mar 19, 2025 at 08:23:34AM +0100, Martin Ågren wrote: > We take a `void *` and immediately cast it. Both callers already have > this pointer as the right type, so tighten the interface and stop > casting. > > Signed-off-by: Martin Ågren > --- > pretty.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/pretty.c b/pretty.c > index 0bc8ad8a9a..a4e5fc5c50 100644 > --- a/pretty.c > +++ b/pretty.c > @@ -1437,9 +1437,8 @@ static void free_decoration_options(const struct decoration_options *opts) > > static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ > const char *placeholder, > - void *context) > + struct format_commit_context *c) > { > - struct format_commit_context *c = context; > const struct commit *commit = c->commit; > const char *msg = c->message; > struct commit_list *p; Makes sense. The function has been introduced all the way back in 9fa708dab1c (Pretty-format: %[+-]x to tweak inter-item newlines, 2009-10-04), and at that point in time the callers only had `void *` contexts available. That has changed eventually, so I agree that it is nice to adapt accordingly now. Patrick