X-Envelope-From: notmuch-bounces@notmuchmail.org  Thu Aug 13 19:44:28 2026
Return-Path: <notmuch-bounces@notmuchmail.org>
X-Original-To: nmbug@yantan.tethera.net
Delivered-To: nmbug@yantan.tethera.net
Received: from yantan.tethera.net (localhost [127.0.0.1])
	by mail.notmuchmail.org (Postfix) with ESMTP id 20D075F874;
	Thu, 13 Aug 2026 19:44:28 +0000 (UTC)
X-Greylist: delayed 482 seconds by postgrey-1.36 at yantan; Thu, 13 Aug 2026 19:44:25 UTC
Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [IPv6:2a0b:5c81:1c1::37])
	by mail.notmuchmail.org (Postfix) with ESMTPS id 755495F7E6
	for <notmuch@notmuchmail.org>; Thu, 13 Aug 2026 19:44:25 +0000 (UTC)
Received: from meesny.iki.fi (meesny.iki.fi [IPv6:2001:67c:2b0:1c1::201])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by lahtoruutu.iki.fi (Postfix) with ESMTPS id 4hLbFX66CMz49Q4V
	for <notmuch@notmuchmail.org>; Thu, 13 Aug 2026 22:36:16 +0300 (EEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu;
	t=1786649776;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=IjTlEEVbAk7XzGtrzGvrlWFN3imaLLFrt2hFzFeBvBE=;
	b=XwoDqSEixFonvsSFw4i87y1cNkxCJte2ZCdYH5q3W7zfQXYZM+6iVS5vT9EmGp5Lkf7sCd
	H6GezHW4Azts2Tnh/xY4KKjk8CyFfGAxyLA8HPuQOh8A/vqB47fG4rX6+jn3IbCMsX+XFo
	HsKLy8rwNFizm4mhv1Bb9OPxmddDQvkPjbrPcGALoqgnbCfWdBZmDyID9loKLcQtU9tV8l
	dbhPLkK66LrY30rtUsGJGFkOoj72M+B9rR3Xa+W9MqBHVmHIz49mxspqYnwP/9RIg4aZWO
	+0k1lOa6VMCI7A9DB7eWw3ZNcu96b8RxxFXLQcGPZggj0PL/W66sovWrl1L+bw==
Received: from c53 (gw1.nor.fi [185.218.193.67])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange secp256r1 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	(Authenticated sender: too)
	by meesny.iki.fi (Postfix) with ESMTPSA id 4hLbFN56m2zyPs;
	Thu, 13 Aug 2026 22:36:08 +0300 (EEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny;
	t=1786649769;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=IjTlEEVbAk7XzGtrzGvrlWFN3imaLLFrt2hFzFeBvBE=;
	b=pOz9dJMw8wWC7swj2EcvG6fcHXylSJrMNiNakJamZ4fmykf/aZ6iaGUuvOY02Cw4jkKJtJ
	IDg1EMe850K/sbkREE4FO75+am2NgoL4o6sMBP3uTo0a6vQ+WUZyW5lEg5yzjT/OPDx33y
	MToJHxHXuZD6niWoURiiYUwugw07o4Q=
ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=meesny; cv=none; t=1786649769;
	b=dGqfVwoM3pfx7/ffALcIRPWsNu/XSHT+sgWKr/TzIJi1v8/Myg26fmr9Mu7iCdUQ93STj4
	MYl1aNTAF+25L3r/EGArOnzQxB6Z/VGc9xqL2YHcdduXx1q0/E4G02XOKau3+SsCck61AL
	KcAzRQJTu7XF+iEBC7Zz9jBF7JwmQAg=
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi;
	s=meesny; t=1786649769;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=IjTlEEVbAk7XzGtrzGvrlWFN3imaLLFrt2hFzFeBvBE=;
	b=Z1e7zgRZ/lAasxmjGJfTjH+yWq14eGqSOe+WYjFZ/KjYW9v+/+59jJ2J3EFypxN6Ss0Xq4
	gkecJZdrVglXq2NseEJvxsdOW3iBc5SGKO+Nh9dQZgLfdv1Cuyfx/VUnMAxUWihfMMEDtN
	jPT7z6n7AxIXlCDbSJutTNixvUKuTpI=
ARC-Authentication-Results: i=1;
	ORIGINATING;
	auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH] cli/reply: refactor add_recipients_from_message.
In-Reply-To: <20260812122222.347345-1-david@tethera.net>
References: <20260812122222.347345-1-david@tethera.net>
User-Agent: Notmuch/0.40+24~gc45207d (https://notmuchmail.org) Emacs/27.1
X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
	$[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
	!)g;OY^,BjTbr)Np:%c_o'jj,Z
Date: Thu, 13 Aug 2026 22:36:07 +0300
Message-ID: <y0ydudr.xxu4y4-too@iki.fi>
MIME-Version: 1.0
Message-ID-Hash: UYZHOSAYO4OTU4SG7BLJDU6TJBXAB5D4
X-Message-ID-Hash: UYZHOSAYO4OTU4SG7BLJDU6TJBXAB5D4
X-MailFrom: tomi.ollila@iki.fi
X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header
X-Mailman-Version: 3.3.3
Precedence: list
List-Id: "Use and development of the notmuch mail system." <notmuch.notmuchmail.org>
List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
List-Owner: <mailto:notmuch-owner@notmuchmail.org>
List-Post: <mailto:notmuch@notmuchmail.org>
List-Subscribe: <mailto:notmuch-join@notmuchmail.org>
List-Unsubscribe: <mailto:notmuch-leave@notmuchmail.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Wed, Aug 12 2026, David Bremner wrote:

> In [1], [2], it was observed that certain versions of gcc miscompiled
> the code using reply_map.
>
> In [3] Dick Marius (with help from Tomi Ollila) suggested setting the
> map to "static const". As others have reported on IRC, this _seems_ to
> work around the gcc bug in question, although I personally have not
> understood the details of why that is the case.
>
> Looking at the code I decided to rewrite it a different way, which at
> least to my eyes is more understandable. If nothing else, it is
> significantly shorter.

LGTM.

Tomi

>
> [1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1135526
> [2]: GCC PR125252
> [3]: id:20260623184003.4144137-2-dick@mrns.nl
> ---
>  notmuch-reply.c | 43 +++++++++----------------------------------
>  1 file changed, 9 insertions(+), 34 deletions(-)
>
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index 44297251..8830b0e9 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -293,24 +293,6 @@ get_sender (GMimeMessage *message)
>      return g_mime_message_get_from (message);
>  }
>  
> -static InternetAddressList *
> -get_to (GMimeMessage *message)
> -{
> -    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO);
> -}
> -
> -static InternetAddressList *
> -get_cc (GMimeMessage *message)
> -{
> -    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_CC);
> -}
> -
> -static InternetAddressList *
> -get_bcc (GMimeMessage *message)
> -{
> -    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_BCC);
> -}
> -
>  /* Augment the recipients of 'reply' from the "Reply-to:", "From:",
>   * "To:", "Cc:", and "Bcc:" headers of 'message'.
>   *
> @@ -329,27 +311,18 @@ add_recipients_from_message (GMimeMessage *reply,
>  			     GMimeMessage *message,
>  			     bool reply_all)
>  {
> -    struct {
> -	InternetAddressList * (*get_header)(GMimeMessage *message);
> -	GMimeAddressType recipient_type;
> -    } reply_to_map[] = {
> -	{ get_sender,   GMIME_ADDRESS_TYPE_TO },
> -	{ get_to,       GMIME_ADDRESS_TYPE_TO },
> -	{ get_cc,       GMIME_ADDRESS_TYPE_CC },
> -	{ get_bcc,      GMIME_ADDRESS_TYPE_BCC },
> -    };
> +    const GMimeAddressType addr_type[] = { GMIME_ADDRESS_TYPE_TO, GMIME_ADDRESS_TYPE_TO,
> +					   GMIME_ADDRESS_TYPE_CC, GMIME_ADDRESS_TYPE_BCC };
> +
>      const char *from_addr = NULL;
>      unsigned int i;
> +    InternetAddressList *recipients;
>      unsigned int n = 0;
>  
> -    for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
> -	InternetAddressList *recipients;
> -
> -	recipients = reply_to_map[i].get_header (message);
> -
> -	n += scan_address_list (recipients, notmuch, reply,
> -				reply_to_map[i].recipient_type, &from_addr);
> +    recipients = get_sender (message);
> +    n += scan_address_list (recipients, notmuch, reply, GMIME_ADDRESS_TYPE_TO, &from_addr);
>  
> +    for (i = 1; i < ARRAY_SIZE (addr_type); i++) {
>  	if (! reply_all && n) {
>  	    /* Stop adding new recipients in reply-to-sender mode if
>  	     * we have added some recipient(s) above.
> @@ -365,6 +338,8 @@ add_recipients_from_message (GMimeMessage *reply,
>  	    if (from_addr)
>  		break;
>  	}
> +	recipients = g_mime_message_get_addresses (message, addr_type[i]);
> +	n += scan_address_list (recipients, notmuch, reply, addr_type[i], &from_addr);
>      }
>  
>      /* If no recipients were added but we found one of the user's
> -- 
> 2.53.0
>
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org
