Fix warnings on Win64 build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162
diff --git a/include/git2/index.h b/include/git2/index.h
index 9d1fd17..fa9a197 100644
--- a/include/git2/index.h
+++ b/include/git2/index.h
@@ -258,7 +258,7 @@ GIT_EXTERN(int) git_index_write_tree_to(git_oid *out, git_index *index, git_repo
* @param index an existing index object
* @return integer of count of current entries
*/
-GIT_EXTERN(unsigned int) git_index_entrycount(const git_index *index);
+GIT_EXTERN(size_t) git_index_entrycount(const git_index *index);
/**
* Clear the contents (all the entries) of an index object.
diff --git a/src/delta.c b/src/delta.c
index 49f7df0..2514dcc 100644
--- a/src/delta.c
+++ b/src/delta.c
@@ -148,7 +148,7 @@ git_delta_create_index(const void *buf, unsigned long bufsize)
/* Determine index hash size. Note that indexing skips the
first byte to allow for optimizing the Rabin's polynomial
initialization in create_delta(). */
- entries = (bufsize - 1) / RABIN_WINDOW;
+ entries = (unsigned int)(bufsize - 1) / RABIN_WINDOW;
if (bufsize >= 0xffffffffUL) {
/*
* Current delta format can't encode offsets into
@@ -317,9 +317,12 @@ unsigned long git_delta_sizeof_index(struct git_delta_index *index)
#define MAX_OP_SIZE (5 + 5 + 1 + RABIN_WINDOW + 7)
void *
-git_delta_create(const struct git_delta_index *index,
- const void *trg_buf, unsigned long trg_size,
- unsigned long *delta_size, unsigned long max_size)
+git_delta_create(
+ const struct git_delta_index *index,
+ const void *trg_buf,
+ unsigned long trg_size,
+ unsigned long *delta_size,
+ unsigned long max_size)
{
unsigned int i, outpos, outsize, moff, msize, val;
int inscnt;
@@ -332,7 +335,7 @@ git_delta_create(const struct git_delta_index *index,
outpos = 0;
outsize = 8192;
if (max_size && outsize >= max_size)
- outsize = max_size + MAX_OP_SIZE + 1;
+ outsize = (unsigned int)(max_size + MAX_OP_SIZE + 1);
out = git__malloc(outsize);
if (!out)
return NULL;
@@ -377,19 +380,19 @@ git_delta_create(const struct git_delta_index *index,
for (entry = index->hash[i]; entry < index->hash[i+1]; entry++) {
const unsigned char *ref = entry->ptr;
const unsigned char *src = data;
- unsigned int ref_size = ref_top - ref;
+ unsigned int ref_size = (unsigned int)(ref_top - ref);
if (entry->val != val)
continue;
if (ref_size > (unsigned int)(top - src))
- ref_size = top - src;
+ ref_size = (unsigned int)(top - src);
if (ref_size <= msize)
break;
while (ref_size-- && *src++ == *ref)
ref++;
if (msize < (unsigned int)(ref - entry->ptr)) {
/* this is our best match so far */
- msize = ref - entry->ptr;
- moff = entry->ptr - ref_data;
+ msize = (unsigned int)(ref - entry->ptr);
+ moff = (unsigned int)(entry->ptr - ref_data);
if (msize >= 4096) /* good enough */
break;
}
diff --git a/src/delta.h b/src/delta.h
index b0b8e41..4ca3279 100644
--- a/src/delta.h
+++ b/src/delta.h
@@ -46,11 +46,12 @@ extern unsigned long git_delta_sizeof_index(struct git_delta_index *index);
* returned and *delta_size is updated with its size. The returned buffer
* must be freed by the caller.
*/
-extern void *
-git_delta_create(const struct git_delta_index *index,
- const void *buf, unsigned long bufsize,
- unsigned long *delta_size,
- unsigned long max_delta_size);
+extern void *git_delta_create(
+ const struct git_delta_index *index,
+ const void *buf,
+ unsigned long bufsize,
+ unsigned long *delta_size,
+ unsigned long max_delta_size);
/*
* diff_delta: create a delta from source buffer to target buffer
@@ -60,15 +61,16 @@ git_delta_create(const struct git_delta_index *index,
* pointer to the buffer with the delta data is returned and *delta_size is
* updated with its size. The returned buffer must be freed by the caller.
*/
-GIT_INLINE(void *)
-git_delta(const void *src_buf, unsigned long src_bufsize,
- const void *trg_buf, unsigned long trg_bufsize,
- unsigned long *delta_size, unsigned long max_delta_size)
+GIT_INLINE(void *) git_delta(
+ const void *src_buf, unsigned long src_bufsize,
+ const void *trg_buf, unsigned long trg_bufsize,
+ unsigned long *delta_size,
+ unsigned long max_delta_size)
{
struct git_delta_index *index = git_delta_create_index(src_buf, src_bufsize);
if (index) {
- void *delta = git_delta_create(index, trg_buf, trg_bufsize,
- delta_size, max_delta_size);
+ void *delta = git_delta_create(
+ index, trg_buf, trg_bufsize, delta_size, max_delta_size);
git_delta_free_index(index);
return delta;
}
@@ -82,9 +84,10 @@ git_delta(const void *src_buf, unsigned long src_bufsize,
* *trg_bufsize is updated with its size. On failure a NULL pointer is
* returned. The returned buffer must be freed by the caller.
*/
-extern void *git_delta_patch(const void *src_buf, unsigned long src_size,
- const void *delta_buf, unsigned long delta_size,
- unsigned long *dst_size);
+extern void *git_delta_patch(
+ const void *src_buf, unsigned long src_size,
+ const void *delta_buf, unsigned long delta_size,
+ unsigned long *dst_size);
/* the smallest possible delta size is 4 bytes */
#define GIT_DELTA_SIZE_MIN 4
@@ -93,9 +96,8 @@ extern void *git_delta_patch(const void *src_buf, unsigned long src_size,
* This must be called twice on the delta data buffer, first to get the
* expected source buffer size, and again to get the target buffer size.
*/
-GIT_INLINE(unsigned long)
-git_delta_get_hdr_size(const unsigned char **datap,
- const unsigned char *top)
+GIT_INLINE(unsigned long) git_delta_get_hdr_size(
+ const unsigned char **datap, const unsigned char *top)
{
const unsigned char *data = *datap;
unsigned long cmd, size = 0;
diff --git a/src/diff_output.c b/src/diff_output.c
index 804325e..3d5e03a 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -262,7 +262,7 @@ static int get_blob_content(
return error;
map->data = (void *)git_blob_rawcontent(*blob);
- map->len = git_blob_rawsize(*blob);
+ map->len = (size_t)git_blob_rawsize(*blob);
return diff_delta_is_binary_by_content(ctxt, delta, file, map);
}
@@ -1236,14 +1236,18 @@ static void set_data_from_blob(
git_blob *blob, git_map *map, git_diff_file *file)
{
if (blob) {
- map->data = (char *)git_blob_rawcontent(blob);
- file->size = map->len = git_blob_rawsize(blob);
+ file->size = git_blob_rawsize(blob);
git_oid_cpy(&file->oid, git_object_id((const git_object *)blob));
file->mode = 0644;
+
+ map->len = (size_t)file->size;
+ map->data = (char *)git_blob_rawcontent(blob);
} else {
- map->data = "";
- file->size = map->len = 0;
+ file->size = 0;
file->flags |= GIT_DIFF_FILE_NO_DATA;
+
+ map->len = 0;
+ map->data = "";
}
}
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c
index a89dffa..469ce78 100644
--- a/src/hash/hash_win32.c
+++ b/src/hash/hash_win32.c
@@ -155,7 +155,7 @@ GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_
{
assert(ctx->ctx.cryptoapi.valid);
- if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, len, 0))
+ if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0))
return -1;
return 0;
@@ -219,7 +219,7 @@ GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx)
GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len)
{
- if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, len, 0) < 0)
+ if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0)
return -1;
return 0;
diff --git a/src/index.c b/src/index.c
index ef644a6..f3ced9e 100644
--- a/src/index.c
+++ b/src/index.c
@@ -488,10 +488,10 @@ int git_index_write_tree_to(git_oid *oid, git_index *index, git_repository *repo
return git_tree__write_index(oid, index, repo);
}
-unsigned int git_index_entrycount(const git_index *index)
+size_t git_index_entrycount(const git_index *index)
{
assert(index);
- return (unsigned int)index->entries.length;
+ return index->entries.length;
}
const git_index_entry *git_index_get_byindex(
@@ -852,7 +852,7 @@ int git_index_conflict_add(git_index *index,
const git_index_entry *their_entry)
{
git_index_entry *entries[3] = { 0 };
- size_t i;
+ unsigned short i;
int ret = 0;
assert (index);
@@ -890,7 +890,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
git_index_entry **their_out,
git_index *index, const char *path)
{
- int pos, stage;
+ int pos, posmax, stage;
git_index_entry *conflict_entry;
int error = GIT_ENOTFOUND;
@@ -903,7 +903,8 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
if ((pos = git_index_find(index, path)) < 0)
return pos;
- while ((unsigned int)pos < git_index_entrycount(index)) {
+ for (posmax = (int)git_index_entrycount(index); pos < posmax; ++pos) {
+
conflict_entry = git_vector_get(&index->entries, pos);
if (index->entries_cmp_path(conflict_entry->path, path) != 0)
@@ -927,8 +928,6 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
default:
break;
};
-
- ++pos;
}
return error;
@@ -936,7 +935,7 @@ int git_index_conflict_get(git_index_entry **ancestor_out,
int git_index_conflict_remove(git_index *index, const char *path)
{
- int pos;
+ int pos, posmax;
git_index_entry *conflict_entry;
int error = 0;
@@ -945,7 +944,9 @@ int git_index_conflict_remove(git_index *index, const char *path)
if ((pos = git_index_find(index, path)) < 0)
return pos;
- while ((unsigned int)pos < git_index_entrycount(index)) {
+ posmax = (int)git_index_entrycount(index);
+
+ while (pos < posmax) {
conflict_entry = git_vector_get(&index->entries, pos);
if (index->entries_cmp_path(conflict_entry->path, path) != 0)
@@ -1520,7 +1521,7 @@ static int write_reuc_extension(git_index *index, git_filebuf *file)
memset(&extension, 0x0, sizeof(struct index_extension));
memcpy(&extension.signature, INDEX_EXT_UNMERGED_SIG, 4);
- extension.extension_size = reuc_buf.size;
+ extension.extension_size = (uint32_t)reuc_buf.size;
error = write_extension(file, &extension, &reuc_buf);
diff --git a/src/iterator.c b/src/iterator.c
index a68a005..6be45a4 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -329,7 +329,7 @@ int git_iterator_for_tree_range(
typedef struct {
git_iterator base;
git_index *index;
- unsigned int current;
+ size_t current;
bool free_index;
} index_iterator;
diff --git a/src/pack-objects.c b/src/pack-objects.c
index e2840a7..008d8f2 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -229,7 +229,7 @@ static int gen_pack_object_header(
}
*hdr++ = c;
- return hdr - hdr_base;
+ return (int)(hdr - hdr_base);
}
static int get_delta(void **out, git_odb *odb, git_pobject *po)
@@ -244,9 +244,10 @@ static int get_delta(void **out, git_odb *odb, git_pobject *po)
git_odb_read(&trg, odb, &po->id) < 0)
goto on_error;
- delta_buf = git_delta(git_odb_object_data(src), git_odb_object_size(src),
- git_odb_object_data(trg), git_odb_object_size(trg),
- &delta_size, 0);
+ delta_buf = git_delta(
+ git_odb_object_data(src), (unsigned long)git_odb_object_size(src),
+ git_odb_object_data(trg), (unsigned long)git_odb_object_size(trg),
+ &delta_size, 0);
if (!delta_buf || delta_size != po->delta_size) {
giterr_set(GITERR_INVALID, "Delta size changed");
@@ -287,7 +288,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
goto on_error;
data = (void *)git_odb_object_data(obj);
- size = git_odb_object_size(obj);
+ size = (unsigned long)git_odb_object_size(obj);
type = git_odb_object_type(obj);
}
@@ -315,7 +316,7 @@ static int write_object(git_buf *buf, git_packbuilder *pb, git_pobject *po)
if (po->delta)
git__free(data);
data = zbuf.ptr;
- size = zbuf.size;
+ size = (unsigned long)zbuf.size;
}
if (git_buf_put(buf, data, size) < 0 ||
@@ -707,7 +708,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
return 0;
/* Now some size filtering heuristics. */
- trg_size = trg_object->size;
+ trg_size = (unsigned long)trg_object->size;
if (!trg_object->delta) {
max_size = trg_size/2 - 20;
ref_depth = 1;
@@ -721,7 +722,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (max_size == 0)
return 0;
- src_size = src_object->size;
+ src_size = (unsigned long)src_object->size;
sizediff = src_size < trg_size ? trg_size - src_size : 0;
if (sizediff >= max_size)
return 0;
@@ -733,7 +734,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (git_odb_read(&obj, pb->odb, &trg_object->id) < 0)
return -1;
- sz = git_odb_object_size(obj);
+ sz = (unsigned long)git_odb_object_size(obj);
trg->data = git__malloc(sz);
GITERR_CHECK_ALLOC(trg->data);
memcpy(trg->data, git_odb_object_data(obj), sz);
@@ -752,7 +753,7 @@ static int try_delta(git_packbuilder *pb, struct unpacked *trg,
if (git_odb_read(&obj, pb->odb, &src_object->id) < 0)
return -1;
- sz = git_odb_object_size(obj);
+ sz = (unsigned long)git_odb_object_size(obj);
src->data = git__malloc(sz);
GITERR_CHECK_ALLOC(src->data);
memcpy(src->data, git_odb_object_data(obj), sz);
@@ -835,7 +836,7 @@ static unsigned long free_unpacked(struct unpacked *n)
git_delta_free_index(n->index);
n->index = NULL;
if (n->data) {
- freed_mem += n->object->size;
+ freed_mem += (unsigned long)n->object->size;
git__free(n->data);
n->data = NULL;
}
@@ -941,7 +942,7 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
GITERR_CHECK_ALLOC(po->delta_data);
memcpy(po->delta_data, zbuf.ptr, zbuf.size);
- po->z_delta_size = zbuf.size;
+ po->z_delta_size = (unsigned long)zbuf.size;
git_buf_clear(&zbuf);
git_packbuilder__cache_lock(pb);
diff --git a/src/reflog.c b/src/reflog.c
index 72a34f6..ac481fb 100644
--- a/src/reflog.c
+++ b/src/reflog.c
@@ -275,7 +275,7 @@ int git_reflog_write(git_reflog *reflog)
if ((error = git_filebuf_write(&fbuf, log.ptr, log.size)) < 0)
goto cleanup;
}
-
+
error = git_filebuf_commit(&fbuf, GIT_REFLOG_FILE_MODE);
goto success;
@@ -411,18 +411,20 @@ size_t git_reflog_entrycount(git_reflog *reflog)
return reflog->entries.length;
}
-const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx)
+GIT_INLINE(size_t) reflog_inverse_index(size_t idx, size_t total)
{
- int pos;
+ return (total - 1) - idx;
+}
+const git_reflog_entry * git_reflog_entry_byindex(git_reflog *reflog, size_t idx)
+{
assert(reflog);
- pos = git_reflog_entrycount(reflog) - (idx + 1);
-
- if (pos < 0)
+ if (idx >= reflog->entries.length)
return NULL;
- return git_vector_get(&reflog->entries, pos);
+ return git_vector_get(
+ &reflog->entries, reflog_inverse_index(idx, reflog->entries.length));
}
const git_oid * git_reflog_entry_id_old(const git_reflog_entry *entry)
@@ -454,7 +456,7 @@ int git_reflog_drop(
size_t idx,
int rewrite_previous_entry)
{
- unsigned int entrycount;
+ size_t entrycount;
git_reflog_entry *entry, *previous;
assert(reflog);
@@ -468,7 +470,8 @@ int git_reflog_drop(
reflog_entry_free(entry);
- if (git_vector_remove(&reflog->entries, entrycount - (idx + 1)) < 0)
+ if (git_vector_remove(
+ &reflog->entries, reflog_inverse_index(idx, entrycount)) < 0)
return -1;
if (!rewrite_previous_entry)
@@ -489,7 +492,7 @@ int git_reflog_drop(
/* ...clear the oid_old member of the "new" oldest entry */
if (git_oid_fromstr(&entry->oid_old, GIT_OID_HEX_ZERO) < 0)
return -1;
-
+
return 0;
}
diff --git a/src/revparse.c b/src/revparse.c
index 79900c4..308b929 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -161,7 +161,7 @@ static int revparse_lookup_object(git_object **out, git_repository *repo, const
static int try_parse_numeric(int *n, const char *curly_braces_content)
{
- int content;
+ int32_t content;
const char *end_ptr;
if (git__strtol32(&content, curly_braces_content, &end_ptr, 10) < 0)
@@ -170,16 +170,17 @@ static int try_parse_numeric(int *n, const char *curly_braces_content)
if (*end_ptr != '\0')
return -1;
- *n = content;
+ *n = (int)content;
return 0;
}
-static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, unsigned int position)
+static int retrieve_previously_checked_out_branch_or_revision(git_object **out, git_reference **base_ref, git_repository *repo, const char *spec, const char *identifier, size_t position)
{
git_reference *ref = NULL;
git_reflog *reflog = NULL;
regex_t preg;
- int numentries, i, cur, error = -1;
+ int error = -1;
+ size_t i, numentries, cur;
const git_reflog_entry *entry;
const char *msg;
regmatch_t regexmatches[2];
@@ -204,7 +205,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
for (i = 0; i < numentries; i++) {
entry = git_reflog_entry_byindex(reflog, i);
msg = git_reflog_entry_message(entry);
-
+
if (regexec(&preg, msg, 2, regexmatches, 0))
continue;
@@ -212,7 +213,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
if (cur > 0)
continue;
-
+
git_buf_put(&buf, msg+regexmatches[1].rm_so, regexmatches[1].rm_eo - regexmatches[1].rm_so);
if ((error = disambiguate_refname(base_ref, repo, git_buf_cstr(&buf))) == 0)
@@ -225,7 +226,7 @@ static int retrieve_previously_checked_out_branch_or_revision(git_object **out,
goto cleanup;
}
-
+
error = GIT_ENOTFOUND;
cleanup:
@@ -236,27 +237,25 @@ cleanup:
return error;
}
-static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned int identifier)
+static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, size_t identifier)
{
git_reflog *reflog;
int error = -1;
- unsigned int numentries;
+ size_t numentries;
const git_reflog_entry *entry;
bool search_by_pos = (identifier <= 100000000);
if (git_reflog_read(&reflog, ref) < 0)
return -1;
- numentries = git_reflog_entrycount(reflog);
+ numentries = git_reflog_entrycount(reflog);
if (search_by_pos) {
if (numentries < identifier + 1) {
giterr_set(
GITERR_REFERENCE,
- "Reflog for '%s' has only %d entries, asked for %d",
- git_reference_name(ref),
- numentries,
- identifier);
+ "Reflog for '%s' has only "PRIuZ" entries, asked for "PRIuZ,
+ git_reference_name(ref), numentries, identifier);
error = GIT_ENOTFOUND;
goto cleanup;
@@ -268,14 +267,14 @@ static int retrieve_oid_from_reflog(git_oid *oid, git_reference *ref, unsigned i
goto cleanup;
} else {
- unsigned int i;
+ size_t i;
git_time commit_time;
for (i = 0; i < numentries; i++) {
entry = git_reflog_entry_byindex(reflog, i);
commit_time = git_reflog_entry_committer(entry)->when;
-
- if (commit_time.time - identifier > 0)
+
+ if (commit_time.time > (git_time_t)identifier)
continue;
git_oid_cpy(oid, git_reflog_entry_id_new(entry));
@@ -291,7 +290,7 @@ cleanup:
return error;
}
-static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, unsigned int position)
+static int retrieve_revobject_from_reflog(git_object **out, git_reference **base_ref, git_repository *repo, const char *identifier, size_t position)
{
git_reference *ref;
git_oid oid;
@@ -380,7 +379,7 @@ static int handle_at_syntax(git_object **out, git_reference **ref, const char *s
if (git__date_parse(×tamp, curly_braces_content) < 0)
goto cleanup;
- error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (unsigned int)timestamp);
+ error = retrieve_revobject_from_reflog(out, ref, repo, git_buf_cstr(&identifier), (size_t)timestamp);
cleanup:
git_buf_free(&identifier);
@@ -394,7 +393,7 @@ static git_otype parse_obj_type(const char *str)
if (!strcmp(str, "tree"))
return GIT_OBJ_TREE;
-
+
if (!strcmp(str, "blob"))
return GIT_OBJ_BLOB;
diff --git a/src/stash.c b/src/stash.c
index 2efdd91..b16637e 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -56,7 +56,7 @@ static int append_abbreviated_oid(git_buf *out, const git_oid *b_commit)
static int append_commit_description(git_buf *out, git_commit* commit)
{
const char *message;
- int pos = 0, len;
+ size_t pos = 0, len;
if (append_abbreviated_oid(out, git_commit_id(commit)) < 0)
return -1;
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 5529537..e137ca9 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -11,7 +11,7 @@
static void plaintext_free(struct git_cred *cred)
{
git_cred_userpass_plaintext *c = (git_cred_userpass_plaintext *)cred;
- int pass_len = strlen(c->password);
+ size_t pass_len = strlen(c->password);
git__free(c->username);
@@ -19,6 +19,8 @@ static void plaintext_free(struct git_cred *cred)
memset(c->password, 0x0, pass_len);
git__free(c->password);
+ memset(c, 0, sizeof(*c));
+
git__free(c);
}
@@ -54,4 +56,4 @@ int git_cred_userpass_plaintext_new(
*cred = &c->parent;
return 0;
-}
\ No newline at end of file
+}
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 8f9715a..195ea28 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -24,7 +24,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
buf->offset += bytes_read;
if (t->packetsize_cb)
- t->packetsize_cb(bytes_read, t->packetsize_payload);
+ t->packetsize_cb((int)bytes_read, t->packetsize_payload);
return (int)(buf->offset - old_len);
}
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 046bc89..b37c4ba 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -94,7 +94,7 @@ typedef struct transport_smart_caps {
include_tag:1;
} transport_smart_caps;
-typedef void (*packetsize_cb)(int received, void *payload);
+typedef void (*packetsize_cb)(size_t received, void *payload);
typedef struct {
git_transport parent;
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 06424cb..99d34e2 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -367,7 +367,7 @@ static int no_sideband(transport_smart *t, struct git_odb_writepack *writepack,
return 0;
}
-struct network_packetsize_payload
+struct network_packetsize_payload
{
git_transfer_progress_callback callback;
void *payload;
@@ -375,7 +375,7 @@ struct network_packetsize_payload
size_t last_fired_bytes;
};
-static void network_packetsize(int received, void *payload)
+static void network_packetsize(size_t received, void *payload)
{
struct network_packetsize_payload *npp = (struct network_packetsize_payload*)payload;
@@ -384,8 +384,8 @@ static void network_packetsize(int received, void *payload)
/* Fire notification if the threshold is reached */
if ((npp->stats->received_bytes - npp->last_fired_bytes) > NETWORK_XFER_THRESHOLD) {
- npp->last_fired_bytes = npp->stats->received_bytes;
- npp->callback(npp->stats, npp->payload);
+ npp->last_fired_bytes = npp->stats->received_bytes;
+ npp->callback(npp->stats, npp->payload);
}
}
@@ -414,7 +414,7 @@ int git_smart__download_pack(
/* We might have something in the buffer already from negotiate_fetch */
if (t->buffer.offset > 0)
- t->packetsize_cb(t->buffer.offset, t->packetsize_payload);
+ t->packetsize_cb((int)t->buffer.offset, t->packetsize_payload);
}
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c
index df6cd87..f3abe85 100644
--- a/src/transports/winhttp.c
+++ b/src/transports/winhttp.c
@@ -376,7 +376,7 @@ replay:
if (!WinHttpReadData(s->request,
(LPVOID)buffer,
- buf_size,
+ (DWORD)buf_size,
&dw_bytes_read))
{
giterr_set(GITERR_OS, "Failed to read data");
diff --git a/src/tree.c b/src/tree.c
index 177ccb9..b3f5c30 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -353,10 +353,9 @@ int git_tree__parse(git_tree *tree, git_odb_object *obj)
return tree_parse_buffer(tree, (char *)obj->raw.data, (char *)obj->raw.data + obj->raw.len);
}
-static unsigned int find_next_dir(const char *dirname, git_index *index, unsigned int start)
+static size_t find_next_dir(const char *dirname, git_index *index, size_t start)
{
- unsigned int i, entries = git_index_entrycount(index);
- size_t dirlen;
+ size_t dirlen, i, entries = git_index_entrycount(index);
dirlen = strlen(dirname);
for (i = start; i < entries; ++i) {
@@ -399,11 +398,10 @@ static int write_tree(
git_repository *repo,
git_index *index,
const char *dirname,
- unsigned int start)
+ size_t start)
{
git_treebuilder *bld = NULL;
-
- unsigned int i, entries = git_index_entrycount(index);
+ size_t i, entries = git_index_entrycount(index);
int error;
size_t dirname_len = strlen(dirname);
const git_tree_cache *cache;
@@ -411,13 +409,11 @@ static int write_tree(
cache = git_tree_cache_get(index->tree, dirname);
if (cache != NULL && cache->entries >= 0){
git_oid_cpy(oid, &cache->oid);
- return find_next_dir(dirname, index, start);
+ return (int)find_next_dir(dirname, index, start);
}
- error = git_treebuilder_create(&bld, NULL);
- if (bld == NULL) {
+ if ((error = git_treebuilder_create(&bld, NULL)) < 0 || bld == NULL)
return -1;
- }
/*
* This loop is unfortunate, but necessary. The index doesn't have
@@ -494,7 +490,7 @@ static int write_tree(
goto on_error;
git_treebuilder_free(bld);
- return i;
+ return (int)i;
on_error:
git_treebuilder_free(bld);
diff --git a/src/vector.c b/src/vector.c
index c758583..5d3bc08 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -165,7 +165,7 @@ int git_vector_search2(
for (i = 0; i < v->length; ++i) {
if (key_lookup(key, v->contents[i]) == 0)
- return i;
+ return (int)i;
}
return GIT_ENOTFOUND;
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index e301290..3a4398b 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -520,17 +520,17 @@ int p_inet_pton(int af, const char* src, void* dst)
struct sockaddr_in6 sin6;
struct sockaddr_in sin;
} sa;
- size_t srcsize;
+ int srcsize;
switch(af)
{
case AF_INET:
sa.sin.sin_family = AF_INET;
- srcsize = sizeof (sa.sin);
+ srcsize = (int)sizeof(sa.sin);
break;
case AF_INET6:
sa.sin6.sin6_family = AF_INET6;
- srcsize = sizeof (sa.sin6);
+ srcsize = (int)sizeof(sa.sin6);
break;
default:
errno = WSAEPFNOSUPPORT;
diff --git a/tests-clar/diff/patch.c b/tests-clar/diff/patch.c
index 16ed255..6a3c5bc 100644
--- a/tests-clar/diff/patch.c
+++ b/tests-clar/diff/patch.c
@@ -113,7 +113,7 @@ void test_diff_patch__to_string(void)
cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, one, another, NULL));
- cl_assert_equal_i(1, git_diff_num_deltas(diff));
+ cl_assert_equal_i(1, (int)git_diff_num_deltas(diff));
cl_git_pass(git_diff_get_patch(&patch, NULL, diff, 0));
diff --git a/tests-clar/index/conflicts.c b/tests-clar/index/conflicts.c
index 790e067..2fbad3e 100644
--- a/tests-clar/index/conflicts.c
+++ b/tests-clar/index/conflicts.c
@@ -134,7 +134,7 @@ void test_index_conflicts__remove(void)
{
const git_index_entry *entry;
size_t i;
-
+
cl_assert(git_index_entrycount(repo_index) == 8);
cl_git_pass(git_index_conflict_remove(repo_index, "conflicts-one.txt"));
diff --git a/tests-clar/index/filemodes.c b/tests-clar/index/filemodes.c
index a2d5df6..6140b11 100644
--- a/tests-clar/index/filemodes.c
+++ b/tests-clar/index/filemodes.c
@@ -22,7 +22,7 @@ void test_index_filemodes__read(void)
static bool expected[6] = { 0, 1, 0, 1, 0, 1 };
cl_git_pass(git_repository_index(&index, g_repo));
- cl_assert_equal_i(6, git_index_entrycount(index));
+ cl_assert_equal_i(6, (int)git_index_entrycount(index));
for (i = 0; i < 6; ++i) {
const git_index_entry *entry = git_index_get_byindex(index, i);
diff --git a/tests-clar/index/inmemory.c b/tests-clar/index/inmemory.c
index c997b96..a5f72c4 100644
--- a/tests-clar/index/inmemory.c
+++ b/tests-clar/index/inmemory.c
@@ -5,7 +5,7 @@ void test_index_inmemory__can_create_an_inmemory_index(void)
git_index *index;
cl_git_pass(git_index_new(&index));
- cl_assert_equal_i(0, git_index_entrycount(index));
+ cl_assert_equal_i(0, (int)git_index_entrycount(index));
git_index_free(index);
}
diff --git a/tests-clar/index/tests.c b/tests-clar/index/tests.c
index 4d613d6..30a5a31 100644
--- a/tests-clar/index/tests.c
+++ b/tests-clar/index/tests.c
@@ -1,8 +1,8 @@
#include "clar_libgit2.h"
#include "index.h"
-static const int index_entry_count = 109;
-static const int index_entry_count_2 = 1437;
+static const size_t index_entry_count = 109;
+static const size_t index_entry_count_2 = 1437;
#define TEST_INDEX_PATH cl_fixture("testrepo.git/index")
#define TEST_INDEX2_PATH cl_fixture("gitgit.index")
#define TEST_INDEXBIG_PATH cl_fixture("big.index")
@@ -99,7 +99,7 @@ void test_index_tests__default_test_index(void)
cl_git_pass(git_index_open(&index, TEST_INDEX_PATH));
cl_assert(index->on_disk);
- cl_assert(git_index_entrycount(index) == (unsigned int)index_entry_count);
+ cl_assert(git_index_entrycount(index) == index_entry_count);
cl_assert(index->entries.sorted);
entries = (git_index_entry **)index->entries.contents;
@@ -122,7 +122,7 @@ void test_index_tests__gitgit_index(void)
cl_git_pass(git_index_open(&index, TEST_INDEX2_PATH));
cl_assert(index->on_disk);
- cl_assert(git_index_entrycount(index) == (unsigned int)index_entry_count_2);
+ cl_assert(git_index_entrycount(index) == index_entry_count_2);
cl_assert(index->entries.sorted);
cl_assert(index->tree != NULL);
diff --git a/tests-clar/network/fetch.c b/tests-clar/network/fetch.c
index 9c37d72..a575b18 100644
--- a/tests-clar/network/fetch.c
+++ b/tests-clar/network/fetch.c
@@ -29,7 +29,7 @@ static int update_tips(const char *refname, const git_oid *a, const git_oid *b,
static void progress(const git_transfer_progress *stats, void *payload)
{
- int *bytes_received = (int*)payload;
+ size_t *bytes_received = (size_t *)payload;
*bytes_received = stats->received_bytes;
}
@@ -37,7 +37,7 @@ static void do_fetch(const char *url, int flag, int n)
{
git_remote *remote;
git_remote_callbacks callbacks;
- int bytes_received = 0;
+ size_t bytes_received = 0;
memset(&callbacks, 0, sizeof(git_remote_callbacks));
callbacks.update_tips = update_tips;
diff --git a/tests-clar/network/fetchlocal.c b/tests-clar/network/fetchlocal.c
index bff0bb0..a0369d0 100644
--- a/tests-clar/network/fetchlocal.c
+++ b/tests-clar/network/fetchlocal.c
@@ -27,7 +27,7 @@ void test_network_fetchlocal__complete(void)
cl_git_pass(git_remote_update_tips(origin));
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(18, refnames.count);
+ cl_assert_equal_i(18, (int)refnames.count);
cl_assert(callcount > 0);
git_strarray_free(&refnames);
@@ -44,7 +44,7 @@ void test_network_fetchlocal__partial(void)
const char *url;
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(1, refnames.count);
+ cl_assert_equal_i(1, (int)refnames.count);
url = cl_git_fixture_url("testrepo.git");
cl_git_pass(git_remote_add(&origin, repo, GIT_REMOTE_ORIGIN, url));
@@ -55,7 +55,7 @@ void test_network_fetchlocal__partial(void)
git_strarray_free(&refnames);
cl_git_pass(git_reference_list(&refnames, repo, GIT_REF_LISTALL));
- cl_assert_equal_i(19, refnames.count); /* 18 remote + 1 local */
+ cl_assert_equal_i(19, (int)refnames.count); /* 18 remote + 1 local */
cl_assert(callcount > 0);
git_strarray_free(&refnames);
diff --git a/tests-clar/object/blob/filter.c b/tests-clar/object/blob/filter.c
index 4b05804..7854898 100644
--- a/tests-clar/object/blob/filter.c
+++ b/tests-clar/object/blob/filter.c
@@ -43,7 +43,7 @@ void test_object_blob_filter__initialize(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
size_t len = (g_len[i] < 0) ? strlen(g_raw[i]) : (size_t)g_len[i];
- g_len[i] = (int)len;
+ g_len[i] = (git_off_t)len;
cl_git_pass(
git_blob_create_frombuffer(&g_oids[i], g_repo, g_raw[i], len)
@@ -66,7 +66,7 @@ void test_object_blob_filter__unfiltered(void)
for (i = 0; i < NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_oids[i]));
cl_assert(g_len[i] == git_blob_rawsize(blob));
- cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], g_len[i]) == 0);
+ cl_assert(memcmp(git_blob_rawcontent(blob), g_raw[i], (size_t)g_len[i]) == 0);
git_blob_free(blob);
}
}
diff --git a/tests-clar/object/tree/duplicateentries.c b/tests-clar/object/tree/duplicateentries.c
index 3052e29..9262f9a 100644
--- a/tests-clar/object/tree/duplicateentries.c
+++ b/tests-clar/object/tree/duplicateentries.c
@@ -42,7 +42,7 @@ static void tree_checker(
git_oid oid;
cl_git_pass(git_tree_lookup(&tree, _repo, tid));
- cl_assert_equal_i(1, git_tree_entrycount(tree));
+ cl_assert_equal_i(1, (int)git_tree_entrycount(tree));
entry = git_tree_entry_byindex(tree, 0);
cl_git_pass(git_oid_fromstr(&oid, expected_sha));
diff --git a/tests-clar/refs/reflog/drop.c b/tests-clar/refs/reflog/drop.c
index d805d1e..21cc847 100644
--- a/tests-clar/refs/reflog/drop.c
+++ b/tests-clar/refs/reflog/drop.c
@@ -4,15 +4,15 @@
static git_repository *g_repo;
static git_reflog *g_reflog;
-static unsigned int entrycount;
+static size_t entrycount;
void test_refs_reflog_drop__initialize(void)
{
git_reference *ref;
-
+
g_repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
-
+
git_reflog_read(&g_reflog, ref);
entrycount = git_reflog_entrycount(g_reflog);
@@ -31,7 +31,7 @@ void test_refs_reflog_drop__dropping_a_non_exisiting_entry_from_the_log_returns_
{
cl_assert_equal_i(GIT_ENOTFOUND, git_reflog_drop(g_reflog, entrycount, 0));
- cl_assert_equal_i(entrycount, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount, git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_drop_an_entry(void)
@@ -39,7 +39,7 @@ void test_refs_reflog_drop__can_drop_an_entry(void)
cl_assert(entrycount > 4);
cl_git_pass(git_reflog_drop(g_reflog, 2, 0));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
@@ -57,7 +57,7 @@ void test_refs_reflog_drop__can_drop_an_entry_and_rewrite_the_log_history(void)
cl_git_pass(git_reflog_drop(g_reflog, 1, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
after_current = git_reflog_entry_byindex(g_reflog, 0);
@@ -72,7 +72,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry(void)
cl_assert(entrycount > 2);
cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 0));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) != 0);
@@ -85,7 +85,7 @@ void test_refs_reflog_drop__can_drop_the_oldest_entry_and_rewrite_the_log_histor
cl_assert(entrycount > 2);
cl_git_pass(git_reflog_drop(g_reflog, entrycount - 1, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
entry = git_reflog_entry_byindex(g_reflog, entrycount - 2);
cl_assert(git_oid_streq(&entry->oid_old, GIT_OID_HEX_ZERO) == 0);
@@ -101,7 +101,7 @@ void test_refs_reflog_drop__can_drop_all_the_entries(void)
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
- cl_assert_equal_i(0, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_i(0, (int)git_reflog_entrycount(g_reflog));
}
void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
@@ -112,7 +112,7 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
cl_git_pass(git_reference_lookup(&ref, g_repo, g_reflog->ref_name));
cl_git_pass(git_reflog_drop(g_reflog, 0, 1));
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
cl_git_pass(git_reflog_write(g_reflog));
git_reflog_free(g_reflog);
@@ -120,5 +120,5 @@ void test_refs_reflog_drop__can_persist_deletion_on_disk(void)
git_reflog_read(&g_reflog, ref);
git_reference_free(ref);
- cl_assert_equal_i(entrycount - 1, git_reflog_entrycount(g_reflog));
+ cl_assert_equal_sz(entrycount - 1, git_reflog_entrycount(g_reflog));
}
diff --git a/tests-clar/refs/reflog/reflog.c b/tests-clar/refs/reflog/reflog.c
index 4c3d0da..8743c8a 100644
--- a/tests-clar/refs/reflog/reflog.c
+++ b/tests-clar/refs/reflog/reflog.c
@@ -66,7 +66,7 @@ void test_refs_reflog_reflog__append_then_read(void)
/* Read and parse the reflog for this branch */
cl_git_pass(git_reflog_read(&reflog, lookedup_ref));
- cl_assert_equal_i(2, git_reflog_entrycount(reflog));
+ cl_assert_equal_i(2, (int)git_reflog_entrycount(reflog));
entry = git_reflog_entry_byindex(reflog, 1);
assert_signature(committer, entry->committer);
@@ -143,7 +143,7 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re
cl_git_pass(git_reflog_read(&reflog, subtrees));
- cl_assert_equal_i(0, git_reflog_entrycount(reflog));
+ cl_assert_equal_i(0, (int)git_reflog_entrycount(reflog));
git_reflog_free(reflog);
git_reference_free(subtrees);
@@ -160,7 +160,7 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
cl_git_pass(git_reflog_read(&reflog, master));
cl_git_pass(git_reflog_write(reflog));
-
+
cl_git_pass(git_reference_rename(master, "refs/moved", 0));
cl_git_fail(git_reflog_write(reflog));
diff --git a/tests-clar/stash/drop.c b/tests-clar/stash/drop.c
index 26b5717..c146e90 100644
--- a/tests-clar/stash/drop.c
+++ b/tests-clar/stash/drop.c
@@ -91,13 +91,13 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
push_three_states();
cl_git_pass(git_reference_lookup(&stash, repo, "refs/stash"));
-
+
cl_git_pass(git_reflog_read(&reflog, stash));
entry = git_reflog_entry_byindex(reflog, 1);
git_oid_cpy(&oid, git_reflog_entry_id_old(entry));
count = git_reflog_entrycount(reflog);
-
+
git_reflog_free(reflog);
cl_git_pass(git_stash_drop(repo, 1));
@@ -106,7 +106,7 @@ void test_stash_drop__dropping_an_entry_rewrites_reflog_history(void)
entry = git_reflog_entry_byindex(reflog, 0);
cl_assert_equal_i(0, git_oid_cmp(&oid, git_reflog_entry_id_old(entry)));
- cl_assert_equal_i(count - 1, git_reflog_entrycount(reflog));
+ cl_assert_equal_sz(count - 1, git_reflog_entrycount(reflog));
git_reflog_free(reflog);
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c
index 04e3ef1..838a043 100644
--- a/tests-clar/status/worktree.c
+++ b/tests-clar/status/worktree.c
@@ -464,7 +464,7 @@ void test_status_worktree__status_file_without_index_or_workdir(void)
cl_git_pass(git_repository_set_workdir(repo, "wd", false));
cl_git_pass(git_index_open(&index, "empty-index"));
- cl_assert_equal_i(0, git_index_entrycount(index));
+ cl_assert_equal_i(0, (int)git_index_entrycount(index));
git_repository_set_index(repo, index);
cl_git_pass(git_status_file(&status, repo, "branch_file.txt"));