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

Re: [PATCH v3 1/2] Fix nonnull errors reported by UBSAN with GCC 7.

From
Johannes Sixt <j6t@kdbg.org>
Date
Apr 17, 2017, 07:59 UTC
Message-ID
<930be745-944f-62f3-3d57-4f1cd6f2df66@kdbg.org>
In-Reply-To
<xmqqy3uzkdm4.fsf@gitster.mtv.corp.google.com>
Am 17.04.2017 um 03:49 schrieb Junio C Hamano:
Show 6 quoted lines
> "Something or NULL" is a name we use for a function that returns
> something (under normal circumstances) or returns NULL.  This
> wrapper is not about returning NULL at all, as far as I can see, and
> is misnamed.  If it is about "avoid moving 0 bytes", similar to how
> COPY_ARRAY() is used in the previous hunk, perhaps MOVE_ARRAY() is a
> better name?

It is not about "avoid moving 0 bytes", but "if we move 0 bytes, then we allow NULL pointers". Plain memmove/memcpy do not allow the pointers to be NULL even if the count is 0. It just so happens that the implementation of memmove_or_null that permits the relaxed condition looks like "avoid moving 0 bytes".

The name was my suggestion, but I agree that it is not the best name. [Sentence about two most difficult things in software engineering omitted for brevity.]

-- Hannes
Previous: Junio C HamanoNext: Johannes Schindelin
Message 14 of 15 in “Fix nonnull errors reported by UBSAN with GCC 7.”
  1. 1/2 Fix nonnull errors reported by UBSAN with GCC 7.Martin Liška, Apr 6, 2017
  2. Jeff KingApr 6, 2017
  3. Martin LiškaApr 6, 2017
  4. René ScharfeApr 6, 2017
  5. Martin LiškaApr 6, 2017
  6. Johannes SixtApr 6, 2017
  7. René ScharfeApr 6, 2017
  8. Johannes SixtApr 6, 2017
  9. Martin LiškaApr 7, 2017
  10. René ScharfeApr 7, 2017
  11. 1/2 add MOVE_ARRAYRené Scharfe, Apr 7, 2017
  12. 2/2 use MOVE_ARRAYRené Scharfe, Apr 7, 2017
  13. Junio C HamanoApr 17, 2017
  14. Johannes SixtApr 17, 2017
  15. Johannes SchindelinApr 6, 2017

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.