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

Re: [PATCH] Replace memcpy with hashcpy when dealing hash copy globally

From
Duy Nguyen <pclouds@gmail.com>
Date
Mar 1, 2014, 02:58 UTC
Message-ID
<CACsJy8Apoz43HPAgdrTHSNgSOcUhv9j258+r0xDJeioY3iogig@mail.gmail.com>
In-Reply-To
<1393636024-17576-1-git-send-email-sunheehnus@gmail.com>
On Sat, Mar 1, 2014 at 8:07 AM, Sun He <sunheehnus@gmail.com> wrote:
Show 6 quoted lines
> Signed-off-by: Sun He <sunheehnus@gmail.com>
> ---
>  Find the potential places with memcpy by the bash command:
>    $ find . | xargs grep "memcpy.*\(.*20.*\)"
>
>  Helped-by: Michael Haggerty<mhagger@alum.mit.edu>

You may want to put this Helped-by before "---" because it's supposed to end up in the final commit. The patch looks straightforward, except..

Show 20 quoted lines
> diff --git a/ppc/sha1.c b/ppc/sha1.c
> index ec6a192..8a87fea 100644
> --- a/ppc/sha1.c
> +++ b/ppc/sha1.c
> @@ -9,6 +9,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include "sha1.h"
> +#include "cache.h"
>
>  extern void ppc_sha1_core(uint32_t *hash, const unsigned char *p,
>                           unsigned int nblocks);
> @@ -67,6 +68,6 @@ int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c)
>                 memset(&c->buf.b[cnt], 0, 56 - cnt);
>         c->buf.l[7] = c->len;
>         ppc_sha1_core(c->hash, c->buf.b, 1);
> -       memcpy(hash, c->hash, 20);
> +       hashcpy(hash, c->hash);
>         return 0;
>  }

cache.h (actually git-compat-util.h that cache.h includes) messes around with system headers by defining this and that macro. The general rule is if cache.h or git-compat-util.h is included, it's the first #include, and system includes will be always in git-compat-util.h (grep '^#include' shows this). Maybe it's best to leave this memcpy alone (and if you do, state so in the commit message with the reason).

-- 
Duy
Previous: Sun HeNext: Tay Ray Chuan
Message 2 of 6 in “Replace memcpy with hashcpy when dealing hash copy globally”
  1. Replace memcpy with hashcpy when dealing hash copy globallySun He, Mar 1, 2014
  2. Duy NguyenMar 1, 2014
  3. Tay Ray ChuanMar 1, 2014
  4. He SunMar 1, 2014
  5. He SunMar 1, 2014
  6. He SunMar 1, 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.