提交 c32f749f 编写于 作者: R René Scharfe 提交者: Shawn O. Pearce

Correct some sizeof(size_t) != sizeof(unsigned long) typing errors

Fix size_t vs. unsigned long pointer mismatch warnings introduced
with the addition of strbuf_detach().
Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
上级 5be507fc
...@@ -152,7 +152,7 @@ struct patch { ...@@ -152,7 +152,7 @@ struct patch {
unsigned int is_rename:1; unsigned int is_rename:1;
struct fragment *fragments; struct fragment *fragments;
char *result; char *result;
unsigned long resultsize; size_t resultsize;
char old_sha1_prefix[41]; char old_sha1_prefix[41];
char new_sha1_prefix[41]; char new_sha1_prefix[41];
struct patch *next; struct patch *next;
......
...@@ -148,12 +148,14 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1, ...@@ -148,12 +148,14 @@ void *sha1_file_to_archive(const char *path, const unsigned char *sha1,
buffer = read_sha1_file(sha1, type, sizep); buffer = read_sha1_file(sha1, type, sizep);
if (buffer && S_ISREG(mode)) { if (buffer && S_ISREG(mode)) {
struct strbuf buf; struct strbuf buf;
size_t size = 0;
strbuf_init(&buf, 0); strbuf_init(&buf, 0);
strbuf_attach(&buf, buffer, *sizep, *sizep + 1); strbuf_attach(&buf, buffer, *sizep, *sizep + 1);
convert_to_working_tree(path, buf.buf, buf.len, &buf); convert_to_working_tree(path, buf.buf, buf.len, &buf);
convert_to_archive(path, buf.buf, buf.len, &buf, commit); convert_to_archive(path, buf.buf, buf.len, &buf, commit);
buffer = strbuf_detach(&buf, sizep); buffer = strbuf_detach(&buf, &size);
*sizep = size;
} }
return buffer; return buffer;
......
...@@ -1512,6 +1512,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int ...@@ -1512,6 +1512,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
static int populate_from_stdin(struct diff_filespec *s) static int populate_from_stdin(struct diff_filespec *s)
{ {
struct strbuf buf; struct strbuf buf;
size_t size = 0;
strbuf_init(&buf, 0); strbuf_init(&buf, 0);
if (strbuf_read(&buf, 0, 0) < 0) if (strbuf_read(&buf, 0, 0) < 0)
...@@ -1519,7 +1520,8 @@ static int populate_from_stdin(struct diff_filespec *s) ...@@ -1519,7 +1520,8 @@ static int populate_from_stdin(struct diff_filespec *s)
strerror(errno)); strerror(errno));
s->should_munmap = 0; s->should_munmap = 0;
s->data = strbuf_detach(&buf, &s->size); s->data = strbuf_detach(&buf, &size);
s->size = size;
s->should_free = 1; s->should_free = 1;
return 0; return 0;
} }
...@@ -1609,9 +1611,11 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) ...@@ -1609,9 +1611,11 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
*/ */
strbuf_init(&buf, 0); strbuf_init(&buf, 0);
if (convert_to_git(s->path, s->data, s->size, &buf)) { if (convert_to_git(s->path, s->data, s->size, &buf)) {
size_t size = 0;
munmap(s->data, s->size); munmap(s->data, s->size);
s->should_munmap = 0; s->should_munmap = 0;
s->data = strbuf_detach(&buf, &s->size); s->data = strbuf_detach(&buf, &size);
s->size = size;
s->should_free = 1; s->should_free = 1;
} }
} }
......
...@@ -119,8 +119,10 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout ...@@ -119,8 +119,10 @@ static int write_entry(struct cache_entry *ce, char *path, const struct checkout
*/ */
strbuf_init(&buf, 0); strbuf_init(&buf, 0);
if (convert_to_working_tree(ce->name, new, size, &buf)) { if (convert_to_working_tree(ce->name, new, size, &buf)) {
size_t newsize = 0;
free(new); free(new);
new = strbuf_detach(&buf, &size); new = strbuf_detach(&buf, &newsize);
size = newsize;
} }
if (to_tempfile) { if (to_tempfile) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册