On 04/06/2017 02:26 PM, René Scharfe wrote: > Am 06.04.2017 um 11:52 schrieb Martin Liška: >> I'm sending (v2), where I updated commit message and wrapped 2 problematic >> places to newly introduced macros that do the check. Follow-up patch can >> change usages of memcpy and memove. > >> diff --git a/apply.c b/apply.c >> index e6dbab26a..eacca29fa 100644 >> --- a/apply.c >> +++ b/apply.c >> @@ -2802,9 +2802,9 @@ static void update_image(struct apply_state *state, >> img->line + applied_pos + preimage_limit, >> (img->nr - (applied_pos + preimage_limit)) * >> sizeof(*img->line)); >> - memcpy(img->line + applied_pos, >> - postimage->line, >> - postimage->nr * sizeof(*img->line)); >> + MEMCPY(img->line + applied_pos, >> + postimage->line, >> + postimage->nr * sizeof(*img->line)); > > Using the existing macro COPY_ARRAY would yield a nicer result: Yes, it's nicer. I'm sending tested version 3. Martin > > COPY_ARRAY(img->line + applied_pos, postimage->line, postimage->nr); > >> if (!state->allow_overlap) >> for (i = 0; i < postimage->nr; i++) >> img->line[applied_pos + i].flag |= LINE_PATCHED; >> diff --git a/builtin/ls-files.c b/builtin/ls-files.c >> index d449e46db..7caeeb6a6 100644 >> --- a/builtin/ls-files.c >> +++ b/builtin/ls-files.c >> @@ -391,7 +391,7 @@ static void prune_cache(const char *prefix, size_t prefixlen) >> } >> last = next; >> } >> - memmove(active_cache, active_cache + pos, >> + MEMMOVE(active_cache, active_cache + pos, >> (last - pos) * sizeof(struct cache_entry *)); >> active_nr = last - pos; >> } > > Perhaps we should add MOVE_ARRAY to complement COPY_ARRAY. > > René >