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

Re: [RFC PATCH 1/2] Replace memset(0) with static initialization where possible

From
Shawn O. Pearce <spearce@spearce.org>
Date
Oct 9, 2008, 19:17 UTC
Message-ID
<20081009191727.GY8203@spearce.org>
In-Reply-To
<NveF6_7LIvvEmRZEvLeTO5lw7EzzmOQkz1WGEMYGSFKDWqSwAeLwBw@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> wrote:
> Is there interest in a patch like this?
I think this is not a worthwhile change.
 
> "Possible" benefits:
> 
>   1) more concise, so it improves readability in most cases
I'm not sure.

Maybe I'm just too used to reading memset(&foo, 0, sizeof(foo)), but {{0},} seems very difficult to read.

>   2) gives compiler more flexibility when optimizing

Shouldn't a good C compiler notice something like a memset and inline it when possible? They already can inline strlen on a constant.

> Drawbacks:
> 
>   1) many lines touched for no functional change
That's a pretty big drawback.

What happens when a struct gets a struct as its first member? Do all the {0,} inits for it have to change to {{0,},} ?

-- 
Shawn.
Previous: Brandon CaseyNext: Brandon Casey
Message 2 of 6 in “Replace memset(0) with static initialization where possible”
  1. 1/2 Replace memset(0) with static initialization where possibleBrandon Casey, Oct 9, 2008
  2. Shawn O. PearceOct 9, 2008
  3. Brandon CaseyOct 9, 2008
  4. Nicolas PitreOct 9, 2008
  5. Brandon CaseyOct 9, 2008
  6. Nicolas PitreOct 9, 2008

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.