Merge branch 'mh/for-each-string-list-item-empty-fix' into maint

Code cmp.std.c nitpick.

* mh/for-each-string-list-item-empty-fix:
  for_each_string_list_item: avoid undefined behavior for empty list
This commit is contained in:
Junio C Hamano 2017-10-18 14:19:00 +09:00
Родитель 181f145de3 ac7da78ede
Коммит 8dc1d0bf64
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -32,8 +32,10 @@ void string_list_clear_func(struct string_list *list, string_list_clear_func_t c
typedef int (*string_list_each_func_t)(struct string_list_item *, void *); typedef int (*string_list_each_func_t)(struct string_list_item *, void *);
int for_each_string_list(struct string_list *list, int for_each_string_list(struct string_list *list,
string_list_each_func_t, void *cb_data); string_list_each_func_t, void *cb_data);
#define for_each_string_list_item(item,list) \ #define for_each_string_list_item(item,list) \
for (item = (list)->items; item < (list)->items + (list)->nr; ++item) for (item = (list)->items; \
item && item < (list)->items + (list)->nr; \
++item)
/* /*
* Apply want to each item in list, retaining only the ones for which * Apply want to each item in list, retaining only the ones for which