Commit 948f00b4 by Russell Belfer

Merge pull request #1933 from libgit2/vmg/gcc-warnings

Warnings for Windows x64 (MSVC) and GCC on Linux
parents ac5e507c d3ed2106
...@@ -57,9 +57,9 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size) ...@@ -57,9 +57,9 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
} }
#define git_array_alloc(a) \ #define git_array_alloc(a) \
((a).size >= (a).asize) ? \ (((a).size >= (a).asize) ? \
git_array_grow(&(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)
......
...@@ -1694,7 +1694,6 @@ done: ...@@ -1694,7 +1694,6 @@ done:
static int checkout_create_conflicts(checkout_data *data) static int checkout_create_conflicts(checkout_data *data)
{ {
git_vector conflicts = GIT_VECTOR_INIT;
checkout_conflictdata *conflict; checkout_conflictdata *conflict;
size_t i; size_t i;
int error = 0; int error = 0;
......
...@@ -660,7 +660,7 @@ static int inject_object(git_indexer *idx, git_oid *id) ...@@ -660,7 +660,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
/* And then the compressed object */ /* And then the compressed object */
git_filebuf_write(&idx->pack_file, buf.ptr, buf.size); git_filebuf_write(&idx->pack_file, buf.ptr, buf.size);
idx->pack->mwf.size += buf.size; idx->pack->mwf.size += buf.size;
entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, buf.size)); entry->crc = htonl(crc32(entry->crc, (unsigned char *)buf.ptr, (uInt)buf.size));
git_buf_free(&buf); git_buf_free(&buf);
/* Write a fake trailer so the pack functions play ball */ /* Write a fake trailer so the pack functions play ball */
......
...@@ -26,7 +26,7 @@ struct unpacked { ...@@ -26,7 +26,7 @@ struct unpacked {
git_pobject *object; git_pobject *object;
void *data; void *data;
struct git_delta_index *index; struct git_delta_index *index;
unsigned int depth; int depth;
}; };
struct tree_walk_context { struct tree_walk_context {
...@@ -659,7 +659,7 @@ static int delta_cacheable(git_packbuilder *pb, unsigned long src_size, ...@@ -659,7 +659,7 @@ static int delta_cacheable(git_packbuilder *pb, unsigned long src_size,
} }
static int try_delta(git_packbuilder *pb, struct unpacked *trg, static int try_delta(git_packbuilder *pb, struct unpacked *trg,
struct unpacked *src, unsigned int max_depth, struct unpacked *src, int max_depth,
unsigned long *mem_usage, int *ret) unsigned long *mem_usage, int *ret)
{ {
git_pobject *trg_object = trg->object; git_pobject *trg_object = trg->object;
......
...@@ -372,7 +372,7 @@ static unsigned char *pack_window_open( ...@@ -372,7 +372,7 @@ static unsigned char *pack_window_open(
* - each byte afterwards: low seven bits are size continuation, * - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues" * with the high bit being "size continues"
*/ */
int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otype type) size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type)
{ {
unsigned char *hdr_base; unsigned char *hdr_base;
unsigned char c; unsigned char c;
...@@ -392,7 +392,7 @@ int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otyp ...@@ -392,7 +392,7 @@ int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otyp
} }
*hdr++ = c; *hdr++ = c;
return (int)(hdr - hdr_base); return (hdr - hdr_base);
} }
......
...@@ -112,7 +112,7 @@ typedef struct git_packfile_stream { ...@@ -112,7 +112,7 @@ typedef struct git_packfile_stream {
git_mwindow *mw; git_mwindow *mw;
} git_packfile_stream; } git_packfile_stream;
int git_packfile__object_header(unsigned char *hdr, unsigned long size, git_otype type); size_t git_packfile__object_header(unsigned char *hdr, size_t size, git_otype type);
int git_packfile_unpack_header( int git_packfile_unpack_header(
size_t *size_p, size_t *size_p,
......
...@@ -834,7 +834,12 @@ int git_path_direach( ...@@ -834,7 +834,12 @@ int git_path_direach(
DIR *dir; DIR *dir;
path_dirent_data de_data; path_dirent_data de_data;
struct dirent *de, *de_buf = (struct dirent *)&de_data; struct dirent *de, *de_buf = (struct dirent *)&de_data;
(void)flags;
#ifdef GIT_USE_ICONV
git_path_iconv_t ic = GIT_PATH_ICONV_INIT; git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
#endif
if (git_path_to_dir(path) < 0) if (git_path_to_dir(path) < 0)
return -1; return -1;
...@@ -846,8 +851,10 @@ int git_path_direach( ...@@ -846,8 +851,10 @@ int git_path_direach(
return -1; return -1;
} }
#ifdef GIT_USE_ICONV
if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
(void)git_path_iconv_init_precompose(&ic); (void)git_path_iconv_init_precompose(&ic);
#endif
while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) { while (p_readdir_r(dir, de_buf, &de) == 0 && de != NULL) {
char *de_path = de->d_name; char *de_path = de->d_name;
...@@ -856,8 +863,12 @@ int git_path_direach( ...@@ -856,8 +863,12 @@ int git_path_direach(
if (git_path_is_dot_or_dotdot(de_path)) if (git_path_is_dot_or_dotdot(de_path))
continue; continue;
if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0 || #ifdef GIT_USE_ICONV
(error = git_buf_put(path, de_path, de_len)) < 0) if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0)
break;
#endif
if ((error = git_buf_put(path, de_path, de_len)) < 0)
break; break;
error = fn(arg, path); error = fn(arg, path);
...@@ -871,7 +882,10 @@ int git_path_direach( ...@@ -871,7 +882,10 @@ int git_path_direach(
} }
closedir(dir); closedir(dir);
#ifdef GIT_USE_ICONV
git_path_iconv_clear(&ic); git_path_iconv_clear(&ic);
#endif
return error; return error;
} }
...@@ -888,7 +902,12 @@ int git_path_dirload( ...@@ -888,7 +902,12 @@ int git_path_dirload(
size_t path_len; size_t path_len;
path_dirent_data de_data; path_dirent_data de_data;
struct dirent *de, *de_buf = (struct dirent *)&de_data; struct dirent *de, *de_buf = (struct dirent *)&de_data;
(void)flags;
#ifdef GIT_USE_ICONV
git_path_iconv_t ic = GIT_PATH_ICONV_INIT; git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
#endif
assert(path && contents); assert(path && contents);
...@@ -903,8 +922,10 @@ int git_path_dirload( ...@@ -903,8 +922,10 @@ int git_path_dirload(
return -1; return -1;
} }
#ifdef GIT_USE_ICONV
if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0) if ((flags & GIT_PATH_DIR_PRECOMPOSE_UNICODE) != 0)
(void)git_path_iconv_init_precompose(&ic); (void)git_path_iconv_init_precompose(&ic);
#endif
path += prefix_len; path += prefix_len;
path_len -= prefix_len; path_len -= prefix_len;
...@@ -917,8 +938,10 @@ int git_path_dirload( ...@@ -917,8 +938,10 @@ int git_path_dirload(
if (git_path_is_dot_or_dotdot(de_path)) if (git_path_is_dot_or_dotdot(de_path))
continue; continue;
#ifdef GIT_USE_ICONV
if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0) if ((error = git_path_iconv(&ic, &de_path, &de_len)) < 0)
break; break;
#endif
alloc_size = path_len + need_slash + de_len + 1 + alloc_extra; alloc_size = path_len + need_slash + de_len + 1 + alloc_extra;
if ((entry_path = git__calloc(alloc_size, 1)) == NULL) { if ((entry_path = git__calloc(alloc_size, 1)) == NULL) {
...@@ -937,7 +960,10 @@ int git_path_dirload( ...@@ -937,7 +960,10 @@ int git_path_dirload(
} }
closedir(dir); closedir(dir);
#ifdef GIT_USE_ICONV
git_path_iconv_clear(&ic); git_path_iconv_clear(&ic);
#endif
if (error != 0) if (error != 0)
giterr_set(GITERR_OS, "Failed to process directory entry in '%s'", path); giterr_set(GITERR_OS, "Failed to process directory entry in '%s'", path);
......
...@@ -425,16 +425,6 @@ extern void git_path_iconv_clear(git_path_iconv_t *ic); ...@@ -425,16 +425,6 @@ extern void git_path_iconv_clear(git_path_iconv_t *ic);
*/ */
extern int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen); extern int git_path_iconv(git_path_iconv_t *ic, char **in, size_t *inlen);
#else
typedef struct {
int unused;
} git_path_iconv_t;
#define GIT_PATH_ICONV_INIT { 0 }
#define git_path_iconv_init_precompose(X) 0
#define git_path_iconv_clear(X) (void)(X)
#define git_path_iconv(X,Y,Z) 0
#endif /* GIT_USE_ICONV */ #endif /* GIT_USE_ICONV */
#endif #endif
...@@ -737,7 +737,10 @@ int git_reference__normalize_name( ...@@ -737,7 +737,10 @@ int git_reference__normalize_name(
int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC; int segment_len, segments_count = 0, error = GIT_EINVALIDSPEC;
unsigned int process_flags; unsigned int process_flags;
bool normalize = (buf != NULL); bool normalize = (buf != NULL);
#ifdef GIT_USE_ICONV
git_path_iconv_t ic = GIT_PATH_ICONV_INIT; git_path_iconv_t ic = GIT_PATH_ICONV_INIT;
#endif
assert(name); assert(name);
...@@ -750,6 +753,7 @@ int git_reference__normalize_name( ...@@ -750,6 +753,7 @@ int git_reference__normalize_name(
if (normalize) if (normalize)
git_buf_clear(buf); git_buf_clear(buf);
#ifdef GIT_USE_ICONV
if ((flags & GIT_REF_FORMAT__PRECOMPOSE_UNICODE) != 0) { if ((flags & GIT_REF_FORMAT__PRECOMPOSE_UNICODE) != 0) {
size_t namelen = strlen(current); size_t namelen = strlen(current);
if ((error = git_path_iconv_init_precompose(&ic)) < 0 || if ((error = git_path_iconv_init_precompose(&ic)) < 0 ||
...@@ -757,6 +761,7 @@ int git_reference__normalize_name( ...@@ -757,6 +761,7 @@ int git_reference__normalize_name(
goto cleanup; goto cleanup;
error = GIT_EINVALIDSPEC; error = GIT_EINVALIDSPEC;
} }
#endif
while (true) { while (true) {
segment_len = ensure_segment_validity(current); segment_len = ensure_segment_validity(current);
...@@ -834,7 +839,9 @@ cleanup: ...@@ -834,7 +839,9 @@ cleanup:
if (error && normalize) if (error && normalize)
git_buf_free(buf); git_buf_free(buf);
#ifdef GIT_USE_ICONV
git_path_iconv_clear(&ic); git_path_iconv_clear(&ic);
#endif
return error; return error;
} }
......
...@@ -1071,6 +1071,9 @@ static void collect_progress( ...@@ -1071,6 +1071,9 @@ static void collect_progress(
{ {
git_vector *paths = payload; git_vector *paths = payload;
(void)completed_steps;
(void)total_steps;
if (path == NULL) if (path == NULL)
return; return;
......
#include "clar_libgit2.h" #include "clar_libgit2.h"
#include "path.h" #include "path.h"
#ifdef GIT_USE_ICONV
static git_path_iconv_t ic; static git_path_iconv_t ic;
static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D"; static char *nfc = "\xC3\x85\x73\x74\x72\xC3\xB6\x6D";
static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D"; static char *nfd = "\x41\xCC\x8A\x73\x74\x72\x6F\xCC\x88\x6D";
#endif
void test_core_iconv__initialize(void) void test_core_iconv__initialize(void)
{ {
#ifdef GIT_USE_ICONV
cl_git_pass(git_path_iconv_init_precompose(&ic)); cl_git_pass(git_path_iconv_init_precompose(&ic));
#endif
} }
void test_core_iconv__cleanup(void) void test_core_iconv__cleanup(void)
{ {
#ifdef GIT_USE_ICONV
git_path_iconv_clear(&ic); git_path_iconv_clear(&ic);
#endif
} }
void test_core_iconv__unchanged(void) void test_core_iconv__unchanged(void)
{ {
#ifdef GIT_USE_ICONV
char *data = "Ascii data", *original = data; char *data = "Ascii data", *original = data;
size_t datalen = strlen(data); size_t datalen = strlen(data);
...@@ -25,10 +32,12 @@ void test_core_iconv__unchanged(void) ...@@ -25,10 +32,12 @@ void test_core_iconv__unchanged(void)
/* There are no high bits set, so this should leave data untouched */ /* There are no high bits set, so this should leave data untouched */
cl_assert(data == original); cl_assert(data == original);
#endif
} }
void test_core_iconv__decomposed_to_precomposed(void) void test_core_iconv__decomposed_to_precomposed(void)
{ {
#ifdef GIT_USE_ICONV
char *data = nfd; char *data = nfd;
size_t datalen = strlen(nfd); size_t datalen = strlen(nfd);
...@@ -38,15 +47,13 @@ void test_core_iconv__decomposed_to_precomposed(void) ...@@ -38,15 +47,13 @@ void test_core_iconv__decomposed_to_precomposed(void)
/* The decomposed nfd string should be transformed to the nfc form /* The decomposed nfd string should be transformed to the nfc form
* (on platforms where iconv is enabled, of course). * (on platforms where iconv is enabled, of course).
*/ */
#ifdef GIT_USE_ICONV
cl_assert_equal_s(nfc, data); cl_assert_equal_s(nfc, data);
#else
cl_assert_equal_s(nfd, data);
#endif #endif
} }
void test_core_iconv__precomposed_is_unmodified(void) void test_core_iconv__precomposed_is_unmodified(void)
{ {
#ifdef GIT_USE_ICONV
char *data = nfc; char *data = nfc;
size_t datalen = strlen(nfc); size_t datalen = strlen(nfc);
...@@ -57,4 +64,5 @@ void test_core_iconv__precomposed_is_unmodified(void) ...@@ -57,4 +64,5 @@ void test_core_iconv__precomposed_is_unmodified(void)
* the high-bit set, the iconv transform should result in no change. * the high-bit set, the iconv transform should result in no change.
*/ */
cl_assert_equal_s(nfc, data); cl_assert_equal_s(nfc, data);
#endif
} }
...@@ -100,7 +100,6 @@ void test_pack_indexer__fix_thin(void) ...@@ -100,7 +100,6 @@ void test_pack_indexer__fix_thin(void)
unsigned char buffer[128]; unsigned char buffer[128];
int fd; int fd;
ssize_t read; ssize_t read;
git_off_t left;
struct stat st; struct stat st;
const char *name = "pack-11f0f69b334728fdd8bc86b80499f22f29d85b15.pack"; const char *name = "pack-11f0f69b334728fdd8bc86b80499f22f29d85b15.pack";
...@@ -108,7 +107,6 @@ void test_pack_indexer__fix_thin(void) ...@@ -108,7 +107,6 @@ void test_pack_indexer__fix_thin(void)
cl_assert(fd != -1); cl_assert(fd != -1);
cl_git_pass(p_stat(name, &st)); cl_git_pass(p_stat(name, &st));
left = st.st_size;
cl_git_pass(git_indexer_new(&idx, ".", NULL, NULL, NULL)); cl_git_pass(git_indexer_new(&idx, ".", NULL, NULL, NULL));
read = p_read(fd, buffer, sizeof(buffer)); read = p_read(fd, buffer, sizeof(buffer));
......
...@@ -232,6 +232,7 @@ void test_repo_init__detect_ignorecase(void) ...@@ -232,6 +232,7 @@ void test_repo_init__detect_ignorecase(void)
void test_repo_init__detect_precompose_unicode_required(void) void test_repo_init__detect_precompose_unicode_required(void)
{ {
#ifdef GIT_USE_ICONV
char *composed = "ḱṷṓn", *decomposed = "ḱṷṓn"; char *composed = "ḱṷṓn", *decomposed = "ḱṷṓn";
struct stat st; struct stat st;
bool found_with_nfd; bool found_with_nfd;
...@@ -240,7 +241,6 @@ void test_repo_init__detect_precompose_unicode_required(void) ...@@ -240,7 +241,6 @@ void test_repo_init__detect_precompose_unicode_required(void)
found_with_nfd = (p_stat(decomposed, &st) == 0); found_with_nfd = (p_stat(decomposed, &st) == 0);
cl_must_pass(p_unlink(composed)); cl_must_pass(p_unlink(composed));
#ifdef GIT_USE_ICONV
assert_config_entry_on_init("core.precomposeunicode", found_with_nfd); assert_config_entry_on_init("core.precomposeunicode", found_with_nfd);
#else #else
assert_config_entry_on_init("core.precomposeunicode", GIT_ENOTFOUND); assert_config_entry_on_init("core.precomposeunicode", GIT_ENOTFOUND);
......
...@@ -147,13 +147,16 @@ static void *delete_refs(void *arg) ...@@ -147,13 +147,16 @@ static void *delete_refs(void *arg)
void test_threads_refdb__edit_while_iterate(void) void test_threads_refdb__edit_while_iterate(void)
{ {
int r, t; int r, t;
git_thread th[THREADS];
int id[THREADS]; int id[THREADS];
git_oid head; git_oid head;
git_reference *ref; git_reference *ref;
char name[128]; char name[128];
git_refdb *refdb; git_refdb *refdb;
#ifdef GIT_THREADS
git_thread th[THREADS];
#endif
g_repo = cl_git_sandbox_init("testrepo2"); g_repo = cl_git_sandbox_init("testrepo2");
cl_git_pass(git_reference_name_to_id(&head, g_repo, "HEAD")); cl_git_pass(git_reference_name_to_id(&head, g_repo, "HEAD"));
...@@ -187,7 +190,6 @@ void test_threads_refdb__edit_while_iterate(void) ...@@ -187,7 +190,6 @@ void test_threads_refdb__edit_while_iterate(void)
#ifdef GIT_THREADS #ifdef GIT_THREADS
cl_git_pass(git_thread_create(&th[t], NULL, fn, &id[t])); cl_git_pass(git_thread_create(&th[t], NULL, fn, &id[t]));
#else #else
th[t] = t;
fn(&id[t]); fn(&id[t]);
#endif #endif
} }
......
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