{"thread":{"id":"35977","subject":"[PATCH] GSoC2014 microprojects #5 Change bundle.c:add_to_ref_list() to use hashcpy()","startedAt":"2014-02-27T14:58:47Z","lastAt":"2014-02-27T21:45:04Z","messageCount":2,"participants":["Sun He","Michael Haggerty"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235480","messageId":"1393513127-32399-1-git-send-email-sunheehnus@gmail.com","threadId":"35977","inReplyTo":null,"subject":"[PATCH] GSoC2014 microprojects #5 Change bundle.c:add_to_ref_list() to use hashcpy()","fromName":"Sun He","fromEmail":"sunheehnus@gmail.com","sentAt":"2014-02-27T14:58:47Z","receivedAt":"2014-02-27T14:58:47Z","isPatch":true,"sender":{"key":"sunheehnus@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2889804?v=4"},"body":"\nSigned-off-by: Sun He <sunheehnus@gmail.com>\n---\n bundle.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex e99065c..7809fbb 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -19,7 +19,7 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,\n \t\tlist->list = xrealloc(list->list,\n \t\t\t\tlist->alloc * sizeof(list->list[0]));\n \t}\n-\tmemcpy(list->list[list->nr].sha1, sha1, 20);\n+\thashcpy(list->list[list->nr].sha1, sha1);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\n }\n-- \n1.7.1\n\n> See if you can find other places where hashcpy() should be used instead of memcpy()\ngrep.c:grep_source_init()\nreflog-walk.c:read_one_reflog()\nppc/sha1.c:ppc_SHA1_Final()\nrefs.c:resolve_gitlink_packed_ref()\n\nWe can find those by the shell command:\n$ find . | xargs grep \"memcpy\\(.*20.*\\)\n\n\nCheers,\nHe Sun\n"},{"id":"235514","messageId":"530FB1E0.5030501@alum.mit.edu","threadId":"35977","inReplyTo":"1393513127-32399-1-git-send-email-sunheehnus@gmail.com","subject":"Re: [PATCH] GSoC2014 microprojects #5 Change bundle.c:add_to_ref_list() to use hashcpy()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-27T21:45:04Z","receivedAt":"2014-02-27T21:45:04Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/27/2014 03:58 PM, Sun He wrote:\n> Signed-off-by: Sun He <sunheehnus@gmail.com>\n> ---\n>  bundle.c |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/bundle.c b/bundle.c\n> index e99065c..7809fbb 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -19,7 +19,7 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,\n>  \t\tlist->list = xrealloc(list->list,\n>  \t\t\t\tlist->alloc * sizeof(list->list[0]));\n>  \t}\n> -\tmemcpy(list->list[list->nr].sha1, sha1, 20);\n> +\thashcpy(list->list[list->nr].sha1, sha1);\n>  \tlist->list[list->nr].name = xstrdup(name);\n>  \tlist->nr++;\n>  }\n> \n\nCorrect (except for the patch formatting problems I mentioned WRT your\nother patch).  Please also note that the subject line after \"[PATCH...]\"\nis taken as the first line of the commit message, so it is inappropriate\nto mention \"GSoC2014\" etc. there.\n\n> -- 1.7.1\n>> See if you can find other places where hashcpy() should be used instead of memcpy()\n> grep.c:grep_source_init()\n> reflog-walk.c:read_one_reflog()\n> ppc/sha1.c:ppc_SHA1_Final()\n> refs.c:resolve_gitlink_packed_ref()\n> \n> We can find those by the shell command:\n> $ find . | xargs grep \"memcpy\\(.*20.*\\)\n\nIt would have been much more helpful if you had submitted patches to fix\nthose other sites.\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"}]}