git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] gpg-interface: trim CR from ssh-keygen

From
Fabian Stelzer <fs@gigacodes.de>
Date
Jan 10, 2022, 12:28 UTC
Message-ID
<20220110122859.3x37a7xdbmcsmuvm@fs>
In-Reply-To
<CAPig+cQMP_Ppg6uywAcFhaVqSoa71dD6UjXbUtC-bvK0WzJnZA@mail.gmail.com>
On 09.01.2022 15:49, Eric Sunshine wrote:
Show 31 quoted lines
>On Wed, Jan 5, 2022 at 5:36 AM Fabian Stelzer <fs@gigacodes.de> wrote:
>> On 05.01.2022 02:09, Eric Sunshine wrote:
>> >> >      line = strchrnul(line + 1, '\n')) {
>> >> >       while (*line == '\n')
>> >> >               line++;
>> >> >       if (!*line)
>> >> >               break;
>> >
>> >Indeed, the existing code is confusing me. I've been staring at it for
>> >several minutes and I think I'm still failing to understand the
>> >purpose of the +1 in the strchrnul() call. Perhaps I'm missing
>> >something obvious(?).
>>
>> This whole loop was basically copied from parse_gpg_output() above. Without
>> the +1 this would always find the same line in the buffer. The +1 skips over
>> the previously found LF.
>
>I still don't see the point of +1 in the strchrnul() call. After:
>
>    line = strchrnul(line + 1, '\n'))
>
>`line` is going to point either at '\n' or at NUL. Then:
>
>    while (*line == '\n')
>        line++;
>
>skips over the '\n' if present. So, by the time the next loop
>iteration starts, `line` will already be pointing past the '\n' we
>just found, thus the +1 seems pointless (and maybe even buggy).
>
>But perhaps I have a blind spot and am missing something obvious...

Hm, yeah. I think you are correct. The while below should make the +1 unnecessary. I think this never mattered to parse_gpg_output() since it is only looking for the [GNUPG:] status line which probably comes first anyway. If it does not then I think the loop will skip over it. Same thing with ssh (but we are changing this whole loop anyway)

Previous: Eric SunshineNext: Fabian Stelzer
Message 22 of 30 in “gpg-interface: trim CR from ssh-keygen -Y find-principals”
  1. gpg-interface: trim CR from ssh-keygen -Y find-principalsJohannes Schindelin via GitGitGadget, Dec 3, 2021
  2. Fabian StelzerDec 3, 2021
  3. Jeff KingDec 3, 2021
  4. Fabian StelzerDec 4, 2021
  5. Junio C HamanoDec 5, 2021
  6. Damien MillerDec 5, 2021
  7. Fabian StelzerDec 6, 2021
  8. gpg-interface: trim CR from ssh-keygenFabian Stelzer, Jan 3, 2022
  9. Eric SunshineJan 3, 2022
  10. Junio C HamanoJan 3, 2022
  11. Eric SunshineJan 4, 2022
  12. Junio C HamanoJan 4, 2022
  13. Eric SunshineJan 4, 2022
  14. Fabian StelzerJan 4, 2022
  15. Junio C HamanoJan 4, 2022
  16. Eric SunshineJan 5, 2022
  17. Fabian StelzerJan 5, 2022
  18. Junio C HamanoJan 5, 2022
  19. Fabian StelzerJan 6, 2022
  20. Junio C HamanoJan 6, 2022
  21. Eric SunshineJan 9, 2022
  22. Fabian StelzerJan 10, 2022
  23. gpg-interface: trim CR from ssh-keygenFabian Stelzer, Jan 7, 2022
  24. Eric SunshineJan 9, 2022
  25. Fabian StelzerJan 10, 2022
  26. Junio C HamanoJan 10, 2022
  27. Junio C HamanoJan 10, 2022
  28. Fabian StelzerDec 9, 2021
  29. Fabian StelzerDec 9, 2021
  30. Fabian StelzerDec 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.