From: He Sun <sunheehnus@gmail.com>
To: Duy Nguyen <pclouds@gmail.com>, git <git@vger.kernel.org>
Subject: Re: [PATCH] Replace memcpy with hashcpy when dealing hash copy globally
Date: Sat, 1 Mar 2014 22:53:45 +0800 [thread overview]
Message-ID: <CAJr59C2oi9Oi=SJMZigw4SnXnRmVG5wQOpWL2eeVv_u1bfKvmg@mail.gmail.com> (raw)
In-Reply-To: <CACsJy8Apoz43HPAgdrTHSNgSOcUhv9j258+r0xDJeioY3iogig@mail.gmail.com>
2014-03-01 10:58 GMT+08:00 Duy Nguyen <pclouds@gmail.com>:
> On Sat, Mar 1, 2014 at 8:07 AM, Sun He <sunheehnus@gmail.com> wrote:
>> 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..
>
Yeah, got it.
Thanks.
>> 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).
Yap, I should follow the general rule. My fault.
Thanks.
What's more,
I have find out all the files that cache.h git-compat-util.h and
builtin.h are not the first #include
==> test-sigchain.c <==
#include "sigchain.h"
==> sigchain.c <==
#include "sigchain.h"
And I checked "sigchain.h", that it includes very little information.
It didn't import any potential errors. But I think it should be placed
after "cache.h" to match the consistence of the general rule.
> --
> Duy
prev parent reply other threads:[~2014-03-01 14:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-01 1:07 [PATCH] Replace memcpy with hashcpy when dealing hash copy globally Sun He
2014-03-01 2:58 ` Duy Nguyen
2014-03-01 9:13 ` Tay Ray Chuan
2014-03-01 14:55 ` He Sun
2014-03-01 14:53 ` He Sun
2014-03-01 14:53 ` He Sun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJr59C2oi9Oi=SJMZigw4SnXnRmVG5wQOpWL2eeVv_u1bfKvmg@mail.gmail.com' \
--to=sunheehnus@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).