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

Re: [PATCH] string-list.h: Add a value to string_list initializer lists

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jun 2, 2014, 10:54 UTC
Message-ID
<vpqa99vr37o.fsf@anie.imag.fr>
In-Reply-To
<1401699504-29826-1-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 11 quoted lines
> Add a NULL value in the end of STRING_LIST_INIT_NODUP and
> STRING_LIST_DUP to initialize `compare_strings_fn`.
>
> Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
> ---
> When I used a malloced string_list to play around with string-list API and
> used the default init_list, it caused a seg fault. After an hour of debugging
> I saw that comapre_strings_fn should be initialized to NULL. In C, even an
> incomplete initialzer initializes every value to NULl or 0, so in normal
> usage in the codebase this problem never occurs. Still it is better to be
> thorough.

Part of this comment should be in the commit message itself. The "I used ..." part should not (it is your experience), but the last two sentences make sense IMHO.

Other than that, the changes sounds good.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tanay AbhraNext: Junio C Hamano
Message 2 of 3 in “string-list.h: Add a value to string_list initializer lists”
  1. string-list.h: Add a value to string_list initializer listsTanay Abhra, Jun 2, 2014
  2. Matthieu MoyJun 2, 2014
  3. Junio C HamanoJun 2, 2014

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.