Skip to content

Commit 8dd8aa4

Browse files
committed
Fix some warnings
1 parent a16e417 commit 8dd8aa4

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/array.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,26 @@
3939
#define GITERR_CHECK_ARRAY(a) GITERR_CHECK_ALLOC((a).ptr)
4040

4141

42-
typedef git_array_t(void) git_array_generic_t;
42+
typedef git_array_t(char) git_array_generic_t;
4343

4444
/* use a generic array for growth so this can return the new item */
45-
GIT_INLINE(void *) git_array_grow(git_array_generic_t *a, size_t item_size)
45+
GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
4646
{
47+
git_array_generic_t *a = _a;
4748
uint32_t new_size = (a->size < 8) ? 8 : a->asize * 3 / 2;
48-
void *new_array = git__realloc(a->ptr, new_size * item_size);
49+
char *new_array = git__realloc(a->ptr, new_size * item_size);
4950
if (!new_array) {
5051
git_array_clear(*a);
5152
return NULL;
5253
} else {
5354
a->ptr = new_array; a->asize = new_size; a->size++;
54-
return (((char *)a->ptr) + (a->size - 1) * item_size);
55+
return a->ptr + (a->size - 1) * item_size;
5556
}
5657
}
5758

5859
#define git_array_alloc(a) \
5960
((a).size >= (a).asize) ? \
60-
git_array_grow((git_array_generic_t *)&(a), sizeof(*(a).ptr)) : \
61+
git_array_grow(&(a), sizeof(*(a).ptr)) : \
6162
(a).ptr ? &(a).ptr[(a).size++] : NULL
6263

6364
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL)

src/blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ int git_blob__create_from_paths(
195195
size = st.st_size;
196196
mode = hint_mode ? hint_mode : st.st_mode;
197197

198-
if (S_ISLNK(hint_mode)) {
198+
if (S_ISLNK(mode)) {
199199
error = write_symlink(oid, odb, content_path, (size_t)size);
200200
} else {
201201
git_vector write_filters = GIT_VECTOR_INIT;

src/diff_patch.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ int git_diff_foreach(
288288
if (diff_required(diff, "git_diff_foreach") < 0)
289289
return -1;
290290

291-
diff_output_init((git_diff_output *)&xo,
292-
&diff->opts, file_cb, hunk_cb, data_cb, payload);
291+
diff_output_init(
292+
&xo.output, &diff->opts, file_cb, hunk_cb, data_cb, payload);
293293
git_xdiff_init(&xo, &diff->opts);
294294

295295
git_vector_foreach(&diff->deltas, idx, patch.delta) {
@@ -300,10 +300,10 @@ int git_diff_foreach(
300300

301301
if (!(error = diff_patch_init_from_diff(&patch, diff, idx))) {
302302

303-
error = diff_patch_file_callback(&patch, (git_diff_output *)&xo);
303+
error = diff_patch_file_callback(&patch, &xo.output);
304304

305305
if (!error)
306-
error = diff_patch_generate(&patch, (git_diff_output *)&xo);
306+
error = diff_patch_generate(&patch, &xo.output);
307307

308308
git_diff_patch_free(&patch);
309309
}
@@ -441,7 +441,7 @@ int git_diff_blobs(
441441
memset(&xo, 0, sizeof(xo));
442442

443443
diff_output_init(
444-
(git_diff_output *)&xo, opts, file_cb, hunk_cb, data_cb, payload);
444+
&xo.output, opts, file_cb, hunk_cb, data_cb, payload);
445445
git_xdiff_init(&xo, opts);
446446

447447
if (!old_path && new_path)
@@ -452,7 +452,7 @@ int git_diff_blobs(
452452
error = diff_patch_from_blobs(
453453
&pd, &xo, old_blob, old_path, new_blob, new_path, opts);
454454

455-
git_diff_patch_free((git_diff_patch *)&pd);
455+
git_diff_patch_free(&pd.patch);
456456

457457
return error;
458458
}
@@ -477,7 +477,7 @@ int git_diff_patch_from_blobs(
477477

478478
memset(&xo, 0, sizeof(xo));
479479

480-
diff_output_to_patch((git_diff_output *)&xo, &pd->patch);
480+
diff_output_to_patch(&xo.output, &pd->patch);
481481
git_xdiff_init(&xo, opts);
482482

483483
error = diff_patch_from_blobs(
@@ -553,7 +553,7 @@ int git_diff_blob_to_buffer(
553553
memset(&xo, 0, sizeof(xo));
554554

555555
diff_output_init(
556-
(git_diff_output *)&xo, opts, file_cb, hunk_cb, data_cb, payload);
556+
&xo.output, opts, file_cb, hunk_cb, data_cb, payload);
557557
git_xdiff_init(&xo, opts);
558558

559559
if (!old_path && buf_path)
@@ -564,7 +564,7 @@ int git_diff_blob_to_buffer(
564564
error = diff_patch_from_blob_and_buffer(
565565
&pd, &xo, old_blob, old_path, buf, buflen, buf_path, opts);
566566

567-
git_diff_patch_free((git_diff_patch *)&pd);
567+
git_diff_patch_free(&pd.patch);
568568

569569
return error;
570570
}
@@ -590,7 +590,7 @@ int git_diff_patch_from_blob_and_buffer(
590590

591591
memset(&xo, 0, sizeof(xo));
592592

593-
diff_output_to_patch((git_diff_output *)&xo, &pd->patch);
593+
diff_output_to_patch(&xo.output, &pd->patch);
594594
git_xdiff_init(&xo, opts);
595595

596596
error = diff_patch_from_blob_and_buffer(
@@ -642,13 +642,13 @@ int git_diff_get_patch(
642642
if ((error = diff_patch_alloc_from_diff(&patch, diff, idx)) < 0)
643643
return error;
644644

645-
diff_output_to_patch((git_diff_output *)&xo, patch);
645+
diff_output_to_patch(&xo.output, patch);
646646
git_xdiff_init(&xo, &diff->opts);
647647

648-
error = diff_patch_file_callback(patch, (git_diff_output *)&xo);
648+
error = diff_patch_file_callback(patch, &xo.output);
649649

650650
if (!error)
651-
error = diff_patch_generate(patch, (git_diff_output *)&xo);
651+
error = diff_patch_generate(patch, &xo.output);
652652

653653
if (!error) {
654654
/* if cumulative diff size is < 0.5 total size, flatten the patch */

0 commit comments

Comments
 (0)