Skip to contentSkip to conversation

GSoC2014 microprojects #5 Change bundle.c:add_to_ref_list() to use hashcpy()

PATCH In review Sun He 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Sun He

author
#0 lore raw

PATCH 1/1 GSoC2014 microprojects #5 Change bundle.c:add_to_ref_list() to use hashcpy()

---
 bundle.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
bundle.c +1 -1
index e99065c..7809fbb 100644
@@ -19,7 +19,7 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,
 		list->list = xrealloc(list->list,
 				list->alloc * sizeof(list->list[0]));
 	}
-	memcpy(list->list[list->nr].sha1, sha1, 20);
+	hashcpy(list->list[list->nr].sha1, sha1);
 	list->list[list->nr].name = xstrdup(name);
 	list->nr++;
 }
Signature · 1 line
1.7.1
Quoted 1 line

See if you can find other places where hashcpy() should be used instead of memcpy()

grep.c:grep_source_init()
reflog-walk.c:read_one_reflog()
ppc/sha1.c:ppc_SHA1_Final()
refs.c:resolve_gitlink_packed_ref()

We can find those by the shell command:

$ find . | xargs grep "memcpy\(.*20.*\)

Cheers,
He Sun

#1 lore raw
Quoted 11 lines · Sun He
---
 bundle.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
bundle.c +0 -0
index e99065c..7809fbb 100644

bundle.c static void add_to_ref_list(const unsigned char *sha1, const char *name, · line 25

Quoted 8 lines
bundle.c +1 -1
@@ -19,7 +19,7 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,
 		list->list = xrealloc(list->list,
 				list->alloc * sizeof(list->list[0]));
 	}
-	memcpy(list->list[list->nr].sha1, sha1, 20);
+	hashcpy(list->list[list->nr].sha1, sha1);
 	list->list[list->nr].name = xstrdup(name);
 	list->nr++;
 }

Correct (except for the patch formatting problems I mentioned WRT your other patch). Please also note that the subject line after "[PATCH...]" is taken as the first line of the commit message, so it is inappropriate to mention "GSoC2014" etc. there.

Quoted 9 lines

-- 1.7.1

Quoted 1 line

See if you can find other places where hashcpy() should be used instead of memcpy()

grep.c:grep_source_init()
reflog-walk.c:read_one_reflog()
ppc/sha1.c:ppc_SHA1_Final()
refs.c:resolve_gitlink_packed_ref()

We can find those by the shell command:

$ find . | xargs grep "memcpy\(.*20.*\)

It would have been much more helpful if you had submitted patches to fix those other sites.

Michael

Signature · 3 lines
Michael Haggerty
[email protected]
http://softwareswirl.blogspot.com/