Commit 8dd8aa48 by Russell Belfer

Fix some warnings

parent a16e4172
......@@ -39,25 +39,26 @@
#define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr)
typedef git_array_t(void) git_array_generic_t;
typedef git_array_t(char) git_array_generic_t;
/* use a generic array for growth so this can return the new item */
GIT_INLINE(void *) git_array_grow(git_array_generic_t *a, size_t item_size)
GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
{
git_array_generic_t *a = _a;
uint32_t new_size = (a->size < 8) ? 8 : a->asize * 3 / 2;
void *new_array = git__realloc(a->ptr, new_size * item_size);
char *new_array = git__realloc(a->ptr, new_size * item_size);
if (!new_array) {
git_array_clear(*a);
return NULL;
} else {
a->ptr = new_array; a->asize = new_size; a->size++;
return (((char *)a->ptr) + (a->size - 1) * item_size);
return a->ptr + (a->size - 1) * item_size;
}
}
#define git_array_alloc(a) \
((a).size >= (a).asize) ? \
git_array_grow((git_array_generic_t *)&(a), sizeof(*(a).ptr)) : \
git_array_grow(&(a), sizeof(*(a).ptr)) : \
(a).ptr ? &(a).ptr[(a).size++] : NULL
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL)
......
......@@ -195,7 +195,7 @@ int git_blob__create_from_paths(
size = st.st_size;
mode = hint_mode ? hint_mode : st.st_mode;
if (S_ISLNK(hint_mode)) {
if (S_ISLNK(mode)) {
error = write_symlink(oid, odb, content_path, (size_t)size);
} else {
git_vector write_filters = GIT_VECTOR_INIT;
......
......@@ -288,8 +288,8 @@ int git_diff_foreach(
if (diff_required(diff, "git_diff_foreach") < 0)
return -1;
diff_output_init((git_diff_output *)&xo,
&diff->opts, file_cb, hunk_cb, data_cb, payload);
diff_output_init(
&xo.output, &diff->opts, file_cb, hunk_cb, data_cb, payload);
git_xdiff_init(&xo, &diff->opts);
git_vector_foreach(&diff->deltas, idx, patch.delta) {
......@@ -300,10 +300,10 @@ int git_diff_foreach(
if (!(error = diff_patch_init_from_diff(&patch, diff, idx))) {
error = diff_patch_file_callback(&patch, (git_diff_output *)&xo);
error = diff_patch_file_callback(&patch, &xo.output);
if (!error)
error = diff_patch_generate(&patch, (git_diff_output *)&xo);
error = diff_patch_generate(&patch, &xo.output);
git_diff_patch_free(&patch);
}
......@@ -441,7 +441,7 @@ int git_diff_blobs(
memset(&xo, 0, sizeof(xo));
diff_output_init(
(git_diff_output *)&xo, opts, file_cb, hunk_cb, data_cb, payload);
&xo.output, opts, file_cb, hunk_cb, data_cb, payload);
git_xdiff_init(&xo, opts);
if (!old_path && new_path)
......@@ -452,7 +452,7 @@ int git_diff_blobs(
error = diff_patch_from_blobs(
&pd, &xo, old_blob, old_path, new_blob, new_path, opts);
git_diff_patch_free((git_diff_patch *)&pd);
git_diff_patch_free(&pd.patch);
return error;
}
......@@ -477,7 +477,7 @@ int git_diff_patch_from_blobs(
memset(&xo, 0, sizeof(xo));
diff_output_to_patch((git_diff_output *)&xo, &pd->patch);
diff_output_to_patch(&xo.output, &pd->patch);
git_xdiff_init(&xo, opts);
error = diff_patch_from_blobs(
......@@ -553,7 +553,7 @@ int git_diff_blob_to_buffer(
memset(&xo, 0, sizeof(xo));
diff_output_init(
(git_diff_output *)&xo, opts, file_cb, hunk_cb, data_cb, payload);
&xo.output, opts, file_cb, hunk_cb, data_cb, payload);
git_xdiff_init(&xo, opts);
if (!old_path && buf_path)
......@@ -564,7 +564,7 @@ int git_diff_blob_to_buffer(
error = diff_patch_from_blob_and_buffer(
&pd, &xo, old_blob, old_path, buf, buflen, buf_path, opts);
git_diff_patch_free((git_diff_patch *)&pd);
git_diff_patch_free(&pd.patch);
return error;
}
......@@ -590,7 +590,7 @@ int git_diff_patch_from_blob_and_buffer(
memset(&xo, 0, sizeof(xo));
diff_output_to_patch((git_diff_output *)&xo, &pd->patch);
diff_output_to_patch(&xo.output, &pd->patch);
git_xdiff_init(&xo, opts);
error = diff_patch_from_blob_and_buffer(
......@@ -642,13 +642,13 @@ int git_diff_get_patch(
if ((error = diff_patch_alloc_from_diff(&patch, diff, idx)) < 0)
return error;
diff_output_to_patch((git_diff_output *)&xo, patch);
diff_output_to_patch(&xo.output, patch);
git_xdiff_init(&xo, &diff->opts);
error = diff_patch_file_callback(patch, (git_diff_output *)&xo);
error = diff_patch_file_callback(patch, &xo.output);
if (!error)
error = diff_patch_generate(patch, (git_diff_output *)&xo);
error = diff_patch_generate(patch, &xo.output);
if (!error) {
/* if cumulative diff size is < 0.5 total size, flatten the patch */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment