Skip to content

Commit 948f00b

Browse files
committed
Merge pull request libgit2#1933 from libgit2/vmg/gcc-warnings
Warnings for Windows x64 (MSVC) and GCC on Linux
2 parents ac5e507 + d3ed210 commit 948f00b

File tree

14 files changed

+62
-29
lines changed

14 files changed

+62
-29
lines changed

src/array.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
5757
}
5858

5959
#define git_array_alloc(a) \
60-
((a).size >= (a).asize) ? \
60+
(((a).size >= (a).asize) ? \
6161
git_array_grow(&(a), sizeof(*(a).ptr)) : \
62-
((a).ptr ? &(a).ptr[(a).size++] : NULL)
62+
((a).ptr ? &(a).ptr[(a).size++] : NULL))
6363

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

src/checkout.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,6 @@ static int checkout_write_merge(
16941694

16951695
static int checkout_create_conflicts(checkout_data *data)
16961696
{
1697-
git_vector conflicts = GIT_VECTOR_INIT;
16981697
checkout_conflictdata *conflict;
16991698
size_t i;
17001699
int error = 0;

src/indexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
660660
/* And then the compressed object */
661661
git_filebuf_write(&idx->pack_file, buf.ptr, buf.size);
662662
idx->pack->mwf.size += buf.size;
663-
entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, buf.size));
663+
entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, (uInt)buf.size));
664664
git_buf_free(&buf);
665665

666666
/* Write a fake trailer so the pack functions play ball */

src/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct unpacked {
2626
git_pobject *object;
2727
void *data;
2828
struct git_delta_index *index;
29-
unsigned int depth;
29+
int depth;
3030
};
3131

3232
struct tree_walk_context {
@@ -659,7 +659,7 @@ static int delta_cacheable(git_packbuilder *pb, unsigned long src_size,
659659
}
660660

661661
static int try_delta(git_packbuilder *pb, struct unpacked *trg,
662-
struct unpacked *src, unsigned int max_depth,
662+
struct unpacked *src, int max_depth,
663663
unsigned long *mem_usage, int *ret)
664664
{
665665
git_pobject *trg_object = trg->object;

src/pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static unsigned char *pack_window_open(
372372
* - each byte afterwards: low seven bits are size continuation,
373373
* with the high bit being "size continues"
374374
*/
375-
int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otype type)
375+
size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type)
376376
{
377377
unsigned char *hdr_base;
378378
unsigned char c;
@@ -392,7 +392,7 @@ int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otyp
392392
}
393393
*hdr++ = c;
394394

395-
return (int)(hdr - hdr_base);
395+
return (hdr - hdr_base);
396396
}
397397

398398

src/pack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ typedef struct git_packfile_stream {
112112
git_mwindow *mw;
113113
} git_packfile_stream;
114114

115-
int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otype type);
115+
size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type);
116116

117117
int git_packfile_unpack_header(
118118
size_t *size_p,

src/path.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,12 @@ int git_path_direach(
834834
DIR *dir;
835835
path_dirent_data de_data;
836836
struct dirent *de, *de_buf = (struct dirent *)&de_data;
837+
838+
(void)flags;
839+
840+
#ifdef GIT_USE_ICONV
837841
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
842+
#endif
838843

839844
if (git_path_to_dir(path) < 0)
840845
return -1;
@@ -846,8 +851,10 @@ int git_path_direach(
846851
return -1;
847852
}
848853

854+
#ifdef GIT_USE_ICONV
849855
if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
850856
(void)git_path_iconv_init_precompose(&ic);
857+
#endif
851858

852859
while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) {
853860
char *de_path = de->d_name;
@@ -856,8 +863,12 @@ int git_path_direach(
856863
if (git_path_is_dot_or_dotdot(de_path))
857864
continue;
858865

859-
if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0 ||
860-
(error = git_buf_put(path, de_path, de_len)) < 0)
866+
#ifdef GIT_USE_ICONV
867+
if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0)
868+
break;
869+
#endif
870+
871+
if ((error = git_buf_put(path, de_path, de_len)) < 0)
861872
break;
862873

863874
error = fn(arg, path);
@@ -871,7 +882,10 @@ int git_path_direach(
871882
}
872883

873884
closedir(dir);
885+
886+
#ifdef GIT_USE_ICONV
874887
git_path_iconv_clear(&ic);
888+
#endif
875889

876890
return error;
877891
}
@@ -888,7 +902,12 @@ int git_path_dirload(
888902
size_t path_len;
889903
path_dirent_data de_data;
890904
struct dirent *de, *de_buf = (struct dirent *)&de_data;
905+
906+
(void)flags;
907+
908+
#ifdef GIT_USE_ICONV
891909
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
910+
#endif
892911

893912
assert(path && contents);
894913

@@ -903,8 +922,10 @@ int git_path_dirload(
903922
return -1;
904923
}
905924

925+
#ifdef GIT_USE_ICONV
906926
if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
907927
(void)git_path_iconv_init_precompose(&ic);
928+
#endif
908929

909930
path += prefix_len;
910931
path_len -= prefix_len;
@@ -917,8 +938,10 @@ int git_path_dirload(
917938
if (git_path_is_dot_or_dotdot(de_path))
918939
continue;
919940

941+
#ifdef GIT_USE_ICONV
920942
if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0)
921943
break;
944+
#endif
922945

923946
alloc_size = path_len + need_slash + de_len + 1 + alloc_extra;
924947
if ((entry_path = git__calloc(alloc_size, 1)) == NULL) {
@@ -937,7 +960,10 @@ int git_path_dirload(
937960
}
938961

939962
closedir(dir);
963+
964+
#ifdef GIT_USE_ICONV
940965
git_path_iconv_clear(&ic);
966+
#endif
941967

942968
if (error != 0)
943969
giterr_set(GITERR_OS, "Failed to process directory entry in '%s'", path);

src/path.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,6 @@ extern void git_path_iconv_clear(git_path_iconv_t *ic);
425425
*/
426426
extern int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen);
427427

428-
#else
429-
430-
typedef struct {
431-
int unused;
432-
} git_path_iconv_t;
433-
#define GIT_PATH_ICONV_INIT { 0 }
434-
#define git_path_iconv_init_precompose(X) 0
435-
#define git_path_iconv_clear(X) (void)(X)
436-
#define git_path_iconv(X,Y,Z) 0
437-
438428
#endif /* GIT_USE_ICONV */
439429

440430
#endif

src/refs.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,10 @@ int git_reference__normalize_name(
737737
int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC;
738738
unsigned int process_flags;
739739
bool normalize = (buf != NULL);
740+
741+
#ifdef GIT_USE_ICONV
740742
git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
743+
#endif
741744

742745
assert(name);
743746

@@ -750,13 +753,15 @@ int git_reference__normalize_name(
750753
if (normalize)
751754
git_buf_clear(buf);
752755

756+
#ifdef GIT_USE_ICONV
753757
if ((flags & GIT_REF_FORMAT__PRECOMPOSE_UNICODE) != 0) {
754758
size_t namelen = strlen(current);
755759
if ((error = git_path_iconv_init_precompose(&ic)) < 0 ||
756760
(error = git_path_iconv(&ic, &current, &namelen)) < 0)
757761
goto cleanup;
758762
error = GIT_EINVALIDSPEC;
759763
}
764+
#endif
760765

761766
while (true) {
762767
segment_len = ensure_segment_validity(current);
@@ -834,7 +839,9 @@ int git_reference__normalize_name(
834839
if (error && normalize)
835840
git_buf_free(buf);
836841

842+
#ifdef GIT_USE_ICONV
837843
git_path_iconv_clear(&ic);
844+
#endif
838845

839846
return error;
840847
}

tests-clar/checkout/conflict.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,9 @@ static void collect_progress(
10711071
{
10721072
git_vector *paths = payload;
10731073

1074+
(void)completed_steps;
1075+
(void)total_steps;
1076+
10741077
if (path == NULL)
10751078
return;
10761079

0 commit comments

Comments
 (0)