Re: [PATCH v2 06/14] cli/reply: make references header creation easier to follow

Subject: Re: [PATCH v2 06/14] cli/reply: make references header creation easier to follow

Date: Sat, 10 Sep 2016 13:23:42 -0300

To: Jani Nikula, notmuch@notmuchmail.org

Cc: Daniel Kahn Gillmor

From: David Bremner


Jani Nikula <jani@nikula.org> writes:

> Just use strdup when original references is not available, instead of
> trying to cram everything into a monster asprintf. There should be no
> functional changes.
> ---
>  notmuch-reply.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index eb07405591fd..c2d7402d40ae 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -538,13 +538,12 @@ create_reply_message(void *ctx,
>      g_mime_object_set_header (GMIME_OBJECT (reply), "In-Reply-To", in_reply_to);
>  
>      orig_references = notmuch_message_get_header (message, "references");
> -    if (!orig_references)
> -	/* Treat errors like missing References headers. */
> -	orig_references = "";
> -    references = talloc_asprintf (ctx, "%s%s%s",
> -				  *orig_references ? orig_references : "",
> -				  *orig_references ? " " : "",
> -				  in_reply_to);
> +    if (orig_references && *orig_references)
> +	references = talloc_asprintf (ctx, "%s %s", orig_references,
> +				      in_reply_to);
> +    else
> +	references = talloc_strdup (ctx, in_reply_to);
> +

fine, and probably applicable earlier if the series stalls.

d

Thread: