Commit d568d585 by Kirill A. Shutemov

CMakefile: add -Wmissing-prototypes and fix warnings

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
parent 51d00446
...@@ -57,7 +57,7 @@ IF (MSVC) ...@@ -57,7 +57,7 @@ IF (MSVC)
SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd") SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd")
SET(CMAKE_C_FLAGS_RELEASE "/MT /O2") SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
ELSE () ELSE ()
SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes") SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes")
IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF () ENDIF ()
......
...@@ -187,7 +187,7 @@ cleanup: ...@@ -187,7 +187,7 @@ cleanup:
return error; return error;
} }
int commit_parse_buffer(git_commit *commit, const void *data, size_t len) int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
{ {
const char *buffer = data; const char *buffer = data;
const char *buffer_end = (const char *)data + len; const char *buffer_end = (const char *)data + len;
...@@ -254,7 +254,7 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len) ...@@ -254,7 +254,7 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len)
int git_commit__parse(git_commit *commit, git_odb_object *obj) int git_commit__parse(git_commit *commit, git_odb_object *obj)
{ {
assert(commit); assert(commit);
return commit_parse_buffer(commit, obj->raw.data, obj->raw.len); return git_commit__parse_buffer(commit, obj->raw.data, obj->raw.len);
} }
#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \ #define GIT_COMMIT_GETTER(_rvalue, _name, _return) \
......
...@@ -24,4 +24,5 @@ struct git_commit { ...@@ -24,4 +24,5 @@ struct git_commit {
void git_commit__free(git_commit *c); void git_commit__free(git_commit *c);
int git_commit__parse(git_commit *commit, git_odb_object *obj); int git_commit__parse(git_commit *commit, git_odb_object *obj);
int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len);
#endif #endif
...@@ -572,7 +572,7 @@ static char *cfg_readline(diskfile_backend *cfg) ...@@ -572,7 +572,7 @@ static char *cfg_readline(diskfile_backend *cfg)
/* /*
* Consume a line, without storing it anywhere * Consume a line, without storing it anywhere
*/ */
void cfg_consume_line(diskfile_backend *cfg) static void cfg_consume_line(diskfile_backend *cfg)
{ {
char *line_start, *line_end; char *line_start, *line_end;
......
...@@ -131,7 +131,7 @@ void git_mwindow_scan_lru( ...@@ -131,7 +131,7 @@ void git_mwindow_scan_lru(
* Close the least recently used window. You should check to see if * Close the least recently used window. You should check to see if
* the file descriptors need closing from time to time. * the file descriptors need closing from time to time.
*/ */
int git_mwindow_close_lru(git_mwindow_file *mwf) static int git_mwindow_close_lru(git_mwindow_file *mwf)
{ {
unsigned int i; unsigned int i;
git_mwindow *lru_w = NULL, *lru_l = NULL; git_mwindow *lru_w = NULL, *lru_l = NULL;
......
...@@ -481,7 +481,7 @@ static int locate_object(char *object_location, loose_backend *backend, const gi ...@@ -481,7 +481,7 @@ static int locate_object(char *object_location, loose_backend *backend, const gi
} }
/* Explore an entry of a directory and see if it matches a short oid */ /* Explore an entry of a directory and see if it matches a short oid */
int fn_locate_object_short_oid(void *state, char *pathbuf) { static int fn_locate_object_short_oid(void *state, char *pathbuf) {
loose_locate_object_state *sstate = (loose_locate_object_state *)state; loose_locate_object_state *sstate = (loose_locate_object_state *)state;
size_t pathbuf_len = strlen(pathbuf); size_t pathbuf_len = strlen(pathbuf);
...@@ -577,7 +577,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos ...@@ -577,7 +577,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos
* *
***********************************************************/ ***********************************************************/
int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
{ {
char object_path[GIT_PATH_MAX]; char object_path[GIT_PATH_MAX];
git_rawobj raw; git_rawobj raw;
...@@ -599,7 +599,7 @@ int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend ...@@ -599,7 +599,7 @@ int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) static int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
{ {
char object_path[GIT_PATH_MAX]; char object_path[GIT_PATH_MAX];
git_rawobj raw; git_rawobj raw;
...@@ -620,7 +620,7 @@ int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_o ...@@ -620,7 +620,7 @@ int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_o
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int loose_backend__read_prefix( static int loose_backend__read_prefix(
git_oid *out_oid, git_oid *out_oid,
void **buffer_p, void **buffer_p,
size_t *len_p, size_t *len_p,
...@@ -661,7 +661,7 @@ int loose_backend__read_prefix( ...@@ -661,7 +661,7 @@ int loose_backend__read_prefix(
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int loose_backend__exists(git_odb_backend *backend, const git_oid *oid) static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
{ {
char object_path[GIT_PATH_MAX]; char object_path[GIT_PATH_MAX];
...@@ -670,7 +670,7 @@ int loose_backend__exists(git_odb_backend *backend, const git_oid *oid) ...@@ -670,7 +670,7 @@ int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
return locate_object(object_path, (loose_backend *)backend, oid) == GIT_SUCCESS; return locate_object(object_path, (loose_backend *)backend, oid) == GIT_SUCCESS;
} }
int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream) static int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
{ {
loose_writestream *stream = (loose_writestream *)_stream; loose_writestream *stream = (loose_writestream *)_stream;
loose_backend *backend = (loose_backend *)_stream->backend; loose_backend *backend = (loose_backend *)_stream->backend;
...@@ -691,13 +691,13 @@ int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream) ...@@ -691,13 +691,13 @@ int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
return git_filebuf_commit_at(&stream->fbuf, final_path); return git_filebuf_commit_at(&stream->fbuf, final_path);
} }
int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len) static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len)
{ {
loose_writestream *stream = (loose_writestream *)_stream; loose_writestream *stream = (loose_writestream *)_stream;
return git_filebuf_write(&stream->fbuf, data, len); return git_filebuf_write(&stream->fbuf, data, len);
} }
void loose_backend__stream_free(git_odb_stream *_stream) static void loose_backend__stream_free(git_odb_stream *_stream)
{ {
loose_writestream *stream = (loose_writestream *)_stream; loose_writestream *stream = (loose_writestream *)_stream;
...@@ -720,7 +720,7 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o ...@@ -720,7 +720,7 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o
return len+1; return len+1;
} }
int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type) static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type)
{ {
loose_backend *backend; loose_backend *backend;
loose_writestream *stream; loose_writestream *stream;
...@@ -772,7 +772,7 @@ int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend ...@@ -772,7 +772,7 @@ int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type) static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
{ {
int error, header_len; int error, header_len;
char final_path[GIT_PATH_MAX], header[64]; char final_path[GIT_PATH_MAX], header[64];
...@@ -815,7 +815,7 @@ cleanup: ...@@ -815,7 +815,7 @@ cleanup:
return error; return error;
} }
void loose_backend__free(git_odb_backend *_backend) static void loose_backend__free(git_odb_backend *_backend)
{ {
loose_backend *backend; loose_backend *backend;
assert(_backend); assert(_backend);
......
...@@ -381,7 +381,7 @@ int pack_backend__read_header(git_rawobj *obj, git_odb_backend *backend, const g ...@@ -381,7 +381,7 @@ int pack_backend__read_header(git_rawobj *obj, git_odb_backend *backend, const g
} }
*/ */
int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) static int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
{ {
struct git_pack_entry e; struct git_pack_entry e;
git_rawobj raw; git_rawobj raw;
...@@ -400,7 +400,7 @@ int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_od ...@@ -400,7 +400,7 @@ int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_od
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int pack_backend__read_prefix( static int pack_backend__read_prefix(
git_oid *out_oid, git_oid *out_oid,
void **buffer_p, void **buffer_p,
size_t *len_p, size_t *len_p,
...@@ -439,13 +439,13 @@ int pack_backend__read_prefix( ...@@ -439,13 +439,13 @@ int pack_backend__read_prefix(
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int pack_backend__exists(git_odb_backend *backend, const git_oid *oid) static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid)
{ {
struct git_pack_entry e; struct git_pack_entry e;
return pack_entry_find(&e, (struct pack_backend *)backend, oid) == GIT_SUCCESS; return pack_entry_find(&e, (struct pack_backend *)backend, oid) == GIT_SUCCESS;
} }
void pack_backend__free(git_odb_backend *_backend) static void pack_backend__free(git_odb_backend *_backend)
{ {
struct pack_backend *backend; struct pack_backend *backend;
size_t i; size_t i;
......
...@@ -1566,7 +1566,7 @@ int git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*c ...@@ -1566,7 +1566,7 @@ int git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*c
return git_futils_direach(refs_path, GIT_PATH_MAX, _dirent_loose_listall, &data); return git_futils_direach(refs_path, GIT_PATH_MAX, _dirent_loose_listall, &data);
} }
int cb__reflist_add(const char *ref, void *data) static int cb__reflist_add(const char *ref, void *data)
{ {
return git_vector_insert((git_vector *)data, git__strdup(ref)); return git_vector_insert((git_vector *)data, git__strdup(ref));
} }
......
...@@ -234,11 +234,6 @@ int git_remote_download(char **filename, git_remote *remote) ...@@ -234,11 +234,6 @@ int git_remote_download(char **filename, git_remote *remote)
return git_fetch_download_pack(filename, remote); return git_fetch_download_pack(filename, remote);
} }
git_headarray *git_remote_tips(git_remote *remote)
{
return &remote->refs;
}
int git_remote_update_tips(struct git_remote *remote) int git_remote_update_tips(struct git_remote *remote)
{ {
int error = GIT_SUCCESS; int error = GIT_SUCCESS;
......
...@@ -70,7 +70,7 @@ struct git_revwalk { ...@@ -70,7 +70,7 @@ struct git_revwalk {
unsigned int sorting; unsigned int sorting;
}; };
commit_list *commit_list_insert(commit_object *item, commit_list **list_p) static commit_list *commit_list_insert(commit_object *item, commit_list **list_p)
{ {
commit_list *new_list = git__malloc(sizeof(commit_list)); commit_list *new_list = git__malloc(sizeof(commit_list));
new_list->item = item; new_list->item = item;
...@@ -79,7 +79,7 @@ commit_list *commit_list_insert(commit_object *item, commit_list **list_p) ...@@ -79,7 +79,7 @@ commit_list *commit_list_insert(commit_object *item, commit_list **list_p)
return new_list; return new_list;
} }
void commit_list_free(commit_list **list_p) static void commit_list_free(commit_list **list_p)
{ {
commit_list *list = *list_p; commit_list *list = *list_p;
...@@ -92,7 +92,7 @@ void commit_list_free(commit_list **list_p) ...@@ -92,7 +92,7 @@ void commit_list_free(commit_list **list_p)
*list_p = NULL; *list_p = NULL;
} }
commit_object *commit_list_pop(commit_list **stack) static commit_object *commit_list_pop(commit_list **stack)
{ {
commit_list *top = *stack; commit_list *top = *stack;
commit_object *item = top ? top->item : NULL; commit_object *item = top ? top->item : NULL;
......
...@@ -221,7 +221,7 @@ static int parse_timezone_offset(const char *buffer, int *offset_out) ...@@ -221,7 +221,7 @@ static int parse_timezone_offset(const char *buffer, int *offset_out)
return GIT_SUCCESS; return GIT_SUCCESS;
} }
int process_next_token(const char **buffer_out, char **storage, static int process_next_token(const char **buffer_out, char **storage,
const char *token_end, const char *right_boundary) const char *token_end, const char *right_boundary)
{ {
int error = process_trimming(*buffer_out, storage, token_end, 0); int error = process_trimming(*buffer_out, storage, token_end, 0);
...@@ -236,7 +236,7 @@ int process_next_token(const char **buffer_out, char **storage, ...@@ -236,7 +236,7 @@ int process_next_token(const char **buffer_out, char **storage,
return GIT_SUCCESS; return GIT_SUCCESS;
} }
const char *scan_for_previous_token(const char *buffer, const char *left_boundary) static const char *scan_for_previous_token(const char *buffer, const char *left_boundary)
{ {
const char *start; const char *start;
...@@ -252,7 +252,7 @@ const char *scan_for_previous_token(const char *buffer, const char *left_boundar ...@@ -252,7 +252,7 @@ const char *scan_for_previous_token(const char *buffer, const char *left_boundar
return start; return start;
} }
int parse_time(git_time_t *time_out, const char *buffer) static int parse_time(git_time_t *time_out, const char *buffer)
{ {
long time; long time;
int error; int error;
......
...@@ -42,7 +42,7 @@ struct tree_key_search { ...@@ -42,7 +42,7 @@ struct tree_key_search {
size_t filename_len; size_t filename_len;
}; };
int entry_search_cmp(const void *key, const void *array_member) static int entry_search_cmp(const void *key, const void *array_member)
{ {
const struct tree_key_search *ksearch = key; const struct tree_key_search *ksearch = key;
const git_tree_entry *entry = array_member; const git_tree_entry *entry = array_member;
...@@ -55,7 +55,7 @@ int entry_search_cmp(const void *key, const void *array_member) ...@@ -55,7 +55,7 @@ int entry_search_cmp(const void *key, const void *array_member)
return result ? result : ((int)ksearch->filename_len - (int)entry->filename_len); return result ? result : ((int)ksearch->filename_len - (int)entry->filename_len);
} }
int entry_sort_cmp(const void *a, const void *b) static int entry_sort_cmp(const void *a, const void *b)
{ {
const git_tree_entry *entry_a = (const git_tree_entry *)(a); const git_tree_entry *entry_a = (const git_tree_entry *)(a);
const git_tree_entry *entry_b = (const git_tree_entry *)(b); const git_tree_entry *entry_b = (const git_tree_entry *)(b);
......
...@@ -498,9 +498,6 @@ BEGIN_TEST(signature4, "creating a zero character signature") ...@@ -498,9 +498,6 @@ BEGIN_TEST(signature4, "creating a zero character signature")
END_TEST END_TEST
/* External declaration for testing the buffer parsing method */
int commit_parse_buffer(git_commit *commit, void *data, size_t len);
BEGIN_TEST(parse2, "parse a whole commit buffer") BEGIN_TEST(parse2, "parse a whole commit buffer")
const int broken_commit_count = sizeof(test_commits_broken) / sizeof(*test_commits_broken); const int broken_commit_count = sizeof(test_commits_broken) / sizeof(*test_commits_broken);
const int working_commit_count = sizeof(test_commits_working) / sizeof(*test_commits_working); const int working_commit_count = sizeof(test_commits_working) / sizeof(*test_commits_working);
...@@ -516,7 +513,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer") ...@@ -516,7 +513,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
memset(commit, 0x0, sizeof(git_commit)); memset(commit, 0x0, sizeof(git_commit));
commit->object.repo = repo; commit->object.repo = repo;
must_fail(commit_parse_buffer( must_fail(git_commit__parse_buffer(
commit, commit,
test_commits_broken[i], test_commits_broken[i],
strlen(test_commits_broken[i])) strlen(test_commits_broken[i]))
...@@ -532,7 +529,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer") ...@@ -532,7 +529,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
memset(commit, 0x0, sizeof(git_commit)); memset(commit, 0x0, sizeof(git_commit));
commit->object.repo = repo; commit->object.repo = repo;
must_pass(commit_parse_buffer( must_pass(git_commit__parse_buffer(
commit, commit,
test_commits_working[i], test_commits_working[i],
strlen(test_commits_working[i])) strlen(test_commits_working[i]))
...@@ -544,7 +541,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer") ...@@ -544,7 +541,7 @@ BEGIN_TEST(parse2, "parse a whole commit buffer")
memset(commit, 0x0, sizeof(git_commit)); memset(commit, 0x0, sizeof(git_commit));
commit->object.repo = repo; commit->object.repo = repo;
must_pass(commit_parse_buffer( must_pass(git_commit__parse_buffer(
commit, commit,
test_commits_working[i], test_commits_working[i],
strlen(test_commits_working[i])) strlen(test_commits_working[i]))
......
...@@ -34,7 +34,7 @@ typedef struct _aux_object { ...@@ -34,7 +34,7 @@ typedef struct _aux_object {
int visited; int visited;
} table_item; } table_item;
uint32_t hash_func(const void *key, int hash_id) static uint32_t hash_func(const void *key, int hash_id)
{ {
uint32_t r; uint32_t r;
const git_oid *id = key; const git_oid *id = key;
...@@ -43,7 +43,7 @@ uint32_t hash_func(const void *key, int hash_id) ...@@ -43,7 +43,7 @@ uint32_t hash_func(const void *key, int hash_id)
return r; return r;
} }
int hash_cmpkey(const void *a, const void *b) static int hash_cmpkey(const void *a, const void *b)
{ {
return git_oid_cmp(a, b); return git_oid_cmp(a, b);
} }
......
...@@ -34,7 +34,7 @@ typedef struct { ...@@ -34,7 +34,7 @@ typedef struct {
int position; int position;
} fake_backend; } fake_backend;
git_odb_backend *new_backend(int position) static git_odb_backend *new_backend(int position)
{ {
fake_backend *b; fake_backend *b;
...@@ -47,7 +47,7 @@ git_odb_backend *new_backend(int position) ...@@ -47,7 +47,7 @@ git_odb_backend *new_backend(int position)
return (git_odb_backend *)b; return (git_odb_backend *)b;
} }
int test_backend_sorting(git_odb *odb) static int test_backend_sorting(git_odb *odb)
{ {
unsigned int i; unsigned int i;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define SUITE_NAME(SNAME) libgit2_suite_##SNAME #define SUITE_NAME(SNAME) libgit2_suite_##SNAME
#define BEGIN_SUITE(SNAME) \ #define BEGIN_SUITE(SNAME) \
git_testsuite *libgit2_suite_##SNAME(void);\
git_testsuite *libgit2_suite_##SNAME(void) {\ git_testsuite *libgit2_suite_##SNAME(void) {\
git_testsuite *_gitsuite = git_testsuite_new(#SNAME); git_testsuite *_gitsuite = git_testsuite_new(#SNAME);
......
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