Re: [PATCH 1/8] pretty: tighten function signature to not take `void *`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <martin.agren@xxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux