{"thread":{"id":"36822","subject":"[PATCH v2] string-list: Add a value to string_list initializer lists","startedAt":"2014-06-03T09:13:18Z","lastAt":"2014-06-03T15:20:39Z","messageCount":2,"participants":["Tanay Abhra","Matthieu Moy"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"243186","messageId":"1401786798-3729-1-git-send-email-tanayabh@gmail.com","threadId":"36822","inReplyTo":null,"subject":"[PATCH v2] string-list: Add a value to string_list initializer lists","fromName":"Tanay Abhra","fromEmail":"tanayabh@gmail.com","sentAt":"2014-06-03T09:13:18Z","receivedAt":"2014-06-03T09:13:18Z","isPatch":true,"sender":{"key":"tanayabh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2097229?v=4"},"body":"STRING_LIST_INIT_{NODUP,DUP} initializers list values only\nfor earlier structure members, relying on the usual\nconvention in C that the omitted members are initailized to\n0, i.e. the former is expanded to the latter:\n\n\tstruct string_list l = STRING_LIST_INIT_DUP;\n\tstruct string_list l = { NULL, 0, 0, 1 };\n\nand the last member that is not mentioned (i.e. 'cmp') is\ninitialized to NULL.\n\nWhile there is nothing wrong in this construct, spelling out\nall the values where the macros are defined will serve also\nas a documentation, so let's do so.\n\nSigned-off-by: Tanay Abhra <tanayabh@gmail.com>\n---\n\nV1: http://thread.gmane.org/gmane.comp.version-control.git/250560\n\n Documentation/technical/api-string-list.txt | 2 ++\n string-list.h                               | 4 ++--\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt\nindex 20be348..f1add51 100644\n--- a/Documentation/technical/api-string-list.txt\n+++ b/Documentation/technical/api-string-list.txt\n@@ -200,3 +200,5 @@ Represents the list itself.\n   You should not tamper with it.\n . Setting the `strdup_strings` member to 1 will strdup() the strings\n   before adding them, see above.\n+. The `compare_strings_fn` member is used to specify a custom compare\n+  function, otherwise `strcmp()` is used as the default function.\ndiff --git a/string-list.h b/string-list.h\nindex de6769c..dd5e294 100644\n--- a/string-list.h\n+++ b/string-list.h\n@@ -15,8 +15,8 @@ struct string_list {\n \tcompare_strings_fn cmp; /* NULL uses strcmp() */\n };\n \n-#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 }\n-#define STRING_LIST_INIT_DUP   { NULL, 0, 0, 1 }\n+#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0, NULL }\n+#define STRING_LIST_INIT_DUP   { NULL, 0, 0, 1, NULL }\n \n void print_string_list(const struct string_list *p, const char *text);\n void string_list_clear(struct string_list *list, int free_util);\n-- \n1.9.0.GIT\n"},{"id":"243188","messageId":"vpqmwduqat4.fsf@anie.imag.fr","threadId":"36822","inReplyTo":"1401786798-3729-1-git-send-email-tanayabh@gmail.com","subject":"Re: [PATCH v2] string-list: Add a value to string_list initializer lists","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-06-03T15:20:39Z","receivedAt":"2014-06-03T15:20:39Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Tanay Abhra <tanayabh@gmail.com> writes:\n\n> diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt\n> index 20be348..f1add51 100644\n> --- a/Documentation/technical/api-string-list.txt\n> +++ b/Documentation/technical/api-string-list.txt\n> @@ -200,3 +200,5 @@ Represents the list itself.\n>    You should not tamper with it.\n>  . Setting the `strdup_strings` member to 1 will strdup() the strings\n>    before adding them, see above.\n> +. The `compare_strings_fn` member is used to specify a custom compare\n> +  function, otherwise `strcmp()` is used as the default function.\n\nIs this change intentional? It seems good, but not really related to the\nchange described in the commit message.\n\nIn any case, this remark should not block patch inclusion, it's trivial\nenough.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}