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

Re: [PATCH v2] http API: fix dangling pointer issue noted by GCC 12.0

From
Taylor Blau <me@ttaylorr.com>
Date
Feb 26, 2022, 18:01 UTC
Message-ID
<YhprAb1f1WYIktCV@nand.local>
In-Reply-To
<patch-v2-1.1-777838267a5-20220225T090816Z-avarab@gmail.com>
On Fri, Feb 25, 2022 at 10:09:11AM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 5 quoted lines
> There's a few possible ways to fix this, but the simplest is to assign
> NULL to "slot->finished" at the end of run_active_slot(), it's the
> only caller that ever assigns non-NULL to it. It was suggested[2] to
> guard that with "if (slot->finished == &finished)", but that'll still
> trigger the warning.

I'm not quite sure that I follow this. This isn't the only spot that assigns non-NULL to "slot->finished", see the assignments in http-walker.c:process_alternates_response() and http.c:finish_active_slot().

But even if it were, I'm not sure how this being the only spot that *writes* non-NULL matters from a reader's perspective.

Looking more at process_alternates_response(), it really looks like this variable wants to hold a tri-state value. I wonder if it would be clearer to replace the NULL/(pointer to) 0/(pointer to) 1 with a UNKNOWN/TRUE/FALSE enum.

Thanks, Taylor

Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 9 of 15 in “http API: fix dangling pointer issue noted by GCC 12.0”
  1. http API: fix dangling pointer issue noted by GCC 12.0Ævar Arnfjörð Bjarmason, Jan 26, 2022
  2. Taylor BlauJan 26, 2022
  3. Junio C HamanoJan 27, 2022
  4. Junio C HamanoJan 27, 2022
  5. Ævar Arnfjörð BjarmasonJan 27, 2022
  6. Junio C HamanoJan 27, 2022
  7. http API: fix dangling pointer issue noted by GCC 12.0Ævar Arnfjörð Bjarmason, Feb 25, 2022
  8. Junio C HamanoFeb 25, 2022
  9. Taylor BlauFeb 26, 2022
  10. http API: fix dangling pointer issue noted by GCC 12.0Ævar Arnfjörð Bjarmason, Mar 25, 2022
  11. Taylor BlauMar 25, 2022
  12. Junio C HamanoMar 26, 2022
  13. Ævar Arnfjörð BjarmasonApr 14, 2022
  14. Junio C HamanoApr 14, 2022
  15. Ævar Arnfjörð BjarmasonApr 15, 2022

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.