mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-11 20:13:24 +00:00
Fix some warnings
This commit is contained in:
parent
a16e41729d
commit
8dd8aa480b
11
src/array.h
11
src/array.h
@ -39,25 +39,26 @@
|
|||||||
#define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr)
|
#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 */
|
/* 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;
|
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) {
|
if (!new_array) {
|
||||||
git_array_clear(*a);
|
git_array_clear(*a);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
a->ptr = new_array; a->asize = new_size; a->size++;
|
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) \
|
#define git_array_alloc(a) \
|
||||||
((a).size >= (a).asize) ? \
|
((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
|
(a).ptr ? &(a).ptr[(a).size++] : NULL
|
||||||
|
|
||||||
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : 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;
|
size = st.st_size;
|
||||||
mode = hint_mode ? hint_mode : st.st_mode;
|
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);
|
error = write_symlink(oid, odb, content_path, (size_t)size);
|
||||||
} else {
|
} else {
|
||||||
git_vector write_filters = GIT_VECTOR_INIT;
|
git_vector write_filters = GIT_VECTOR_INIT;
|
||||||
|
@ -288,8 +288,8 @@ int git_diff_foreach(
|
|||||||
if (diff_required(diff, "git_diff_foreach") < 0)
|
if (diff_required(diff, "git_diff_foreach") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
diff_output_init((git_diff_output *)&xo,
|
diff_output_init(
|
||||||
&diff->opts, file_cb, hunk_cb, data_cb, payload);
|
&xo.output, &diff->opts, file_cb, hunk_cb, data_cb, payload);
|
||||||
git_xdiff_init(&xo, &diff->opts);
|
git_xdiff_init(&xo, &diff->opts);
|
||||||
|
|
||||||
git_vector_foreach(&diff->deltas, idx, patch.delta) {
|
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))) {
|
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)
|
if (!error)
|
||||||
error = diff_patch_generate(&patch, (git_diff_output *)&xo);
|
error = diff_patch_generate(&patch, &xo.output);
|
||||||
|
|
||||||
git_diff_patch_free(&patch);
|
git_diff_patch_free(&patch);
|
||||||
}
|
}
|
||||||
@ -441,7 +441,7 @@ int git_diff_blobs(
|
|||||||
memset(&xo, 0, sizeof(xo));
|
memset(&xo, 0, sizeof(xo));
|
||||||
|
|
||||||
diff_output_init(
|
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);
|
git_xdiff_init(&xo, opts);
|
||||||
|
|
||||||
if (!old_path && new_path)
|
if (!old_path && new_path)
|
||||||
@ -452,7 +452,7 @@ int git_diff_blobs(
|
|||||||
error = diff_patch_from_blobs(
|
error = diff_patch_from_blobs(
|
||||||
&pd, &xo, old_blob, old_path, new_blob, new_path, opts);
|
&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;
|
return error;
|
||||||
}
|
}
|
||||||
@ -477,7 +477,7 @@ int git_diff_patch_from_blobs(
|
|||||||
|
|
||||||
memset(&xo, 0, sizeof(xo));
|
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);
|
git_xdiff_init(&xo, opts);
|
||||||
|
|
||||||
error = diff_patch_from_blobs(
|
error = diff_patch_from_blobs(
|
||||||
@ -553,7 +553,7 @@ int git_diff_blob_to_buffer(
|
|||||||
memset(&xo, 0, sizeof(xo));
|
memset(&xo, 0, sizeof(xo));
|
||||||
|
|
||||||
diff_output_init(
|
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);
|
git_xdiff_init(&xo, opts);
|
||||||
|
|
||||||
if (!old_path && buf_path)
|
if (!old_path && buf_path)
|
||||||
@ -564,7 +564,7 @@ int git_diff_blob_to_buffer(
|
|||||||
error = diff_patch_from_blob_and_buffer(
|
error = diff_patch_from_blob_and_buffer(
|
||||||
&pd, &xo, old_blob, old_path, buf, buflen, buf_path, opts);
|
&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;
|
return error;
|
||||||
}
|
}
|
||||||
@ -590,7 +590,7 @@ int git_diff_patch_from_blob_and_buffer(
|
|||||||
|
|
||||||
memset(&xo, 0, sizeof(xo));
|
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);
|
git_xdiff_init(&xo, opts);
|
||||||
|
|
||||||
error = diff_patch_from_blob_and_buffer(
|
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)
|
if ((error = diff_patch_alloc_from_diff(&patch, diff, idx)) < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
diff_output_to_patch((git_diff_output *)&xo, patch);
|
diff_output_to_patch(&xo.output, patch);
|
||||||
git_xdiff_init(&xo, &diff->opts);
|
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)
|
if (!error)
|
||||||
error = diff_patch_generate(patch, (git_diff_output *)&xo);
|
error = diff_patch_generate(patch, &xo.output);
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
/* if cumulative diff size is < 0.5 total size, flatten the patch */
|
/* if cumulative diff size is < 0.5 total size, flatten the patch */
|
||||||
|
Loading…
Reference in New Issue
Block a user