git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org,  Patrick Steinhardt <ps@pks.im>,
	 Elijah Newren <newren@gmail.com>,  Jeff King <peff@peff.net>,
	 "brian m . carlson" <sandals@crustytoothpaste.net>,
	 Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	 Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH 1/5] gpg-interface: simplify ssh fingerprint parsing
Date: Tue, 28 Oct 2025 09:45:12 -0700	[thread overview]
Message-ID: <xmqq4irjdlgn.fsf@gitster.g> (raw)
In-Reply-To: <20251028081232.3068147-2-christian.couder@gmail.com> (Christian Couder's message of "Tue, 28 Oct 2025 09:12:28 +0100")

Christian Couder <christian.couder@gmail.com> writes:

> In "gpg-interface.c", the 'parse_ssh_output()' function takes a
> 'struct signature_check *sigc' argument and populates many members of
> this 'sigc' using information parsed from 'sigc->output' which
> contains the ouput of an `ssh-keygen -Y ...` command that was used to
> verify an SSH signature.
>
> When it populates 'sigc->fingerprint' though, it uses
> `xstrdup(strstr(line, "key ") + 4)` while `strstr(line, "key ")` has
> already been computed a few lines above and is already available in
> the `key` variable.
>
> Let's simplify this.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
>  gpg-interface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gpg-interface.c b/gpg-interface.c
> index 2f4f0e32cb..91d1b58cb4 100644
> --- a/gpg-interface.c
> +++ b/gpg-interface.c
> @@ -443,7 +443,7 @@ static void parse_ssh_output(struct signature_check *sigc)
>  
>  	key = strstr(line, "key ");
>  	if (key) {
> -		sigc->fingerprint = xstrdup(strstr(line, "key ") + 4);
> +		sigc->fingerprint = xstrdup(key + 4);

Looks like an obvious avoidance of duplicated work.  I am not sure
if "find 'key ' anywhere on the line and take the first one" is a
sensible validation, but that is not a fault of this patch ;-)

>  		sigc->key = xstrdup(sigc->fingerprint);
>  	} else {
>  		/*

  reply	other threads:[~2025-10-28 16:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28  8:12 [PATCH 0/5] fast-export/import: cleanups and translation Christian Couder
2025-10-28  8:12 ` [PATCH 1/5] gpg-interface: simplify ssh fingerprint parsing Christian Couder
2025-10-28 16:45   ` Junio C Hamano [this message]
2025-10-28  8:12 ` [PATCH 2/5] gpg-interface: use left shift to define GPG_VERIFY_* Christian Couder
2025-10-28  8:12 ` [PATCH 3/5] fast-export: mark strings for translation Christian Couder
2025-10-28 13:43   ` Junio C Hamano
2025-10-29 14:29     ` Christian Couder
2025-10-29 16:12       ` Junio C Hamano
2025-10-30 12:39         ` Christian Couder
2025-10-28  8:12 ` [PATCH 4/5] fast-import: " Christian Couder
2025-10-28 16:46   ` Junio C Hamano
2025-10-28  8:12 ` [PATCH 5/5] gpg-interface: mark a string " Christian Couder
2025-10-30 12:33 ` [PATCH v2 0/5] fast-export/import: cleanups and translation Christian Couder
2025-10-30 12:33   ` [PATCH v2 1/5] gpg-interface: simplify ssh fingerprint parsing Christian Couder
2025-10-30 12:33   ` [PATCH v2 2/5] gpg-interface: use left shift to define GPG_VERIFY_* Christian Couder
2025-10-30 12:33   ` [PATCH v2 3/5] fast-export: mark strings for translation Christian Couder
2025-10-30 12:33   ` [PATCH v2 4/5] fast-import: " Christian Couder
2025-10-31 19:35     ` Elijah Newren
2025-10-30 12:33   ` [PATCH v2 5/5] gpg-interface: mark a string " Christian Couder
2025-10-30 18:14   ` [PATCH v2 0/5] fast-export/import: cleanups and translation Junio C Hamano
2025-10-31 19:37   ` Elijah Newren
2025-11-01 15:16     ` Christian Couder

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=xmqq4irjdlgn.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    --cc=sandals@crustytoothpaste.net \
    /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 NNTP newsgroup(s).