Skip to content

Commit 71a4c1f

Browse files
author
Vicent Martí
committed
Merge pull request libgit2#384 from kiryl/warnings
Add more -W flags to CFLAGS
2 parents a807607 + d568d58 commit 71a4c1f

19 files changed

+50
-53
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ IF (MSVC)
5858
SET(CMAKE_C_FLAGS_DEBUG "/Od /DEBUG /MTd")
5959
SET(CMAKE_C_FLAGS_RELEASE "/MT /O2")
6060
ELSE ()
61-
SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra")
61+
SET(CMAKE_C_FLAGS "-O2 -g -Wall -Wextra -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes")
6262
IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to
6363
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
6464
ENDIF ()

src/cache.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ void git_cache_free(git_cache *cache)
5858

5959
void *git_cache_get(git_cache *cache, const git_oid *oid)
6060
{
61-
const uint32_t *hash;
61+
uint32_t hash;
6262
cache_node *node = NULL;
6363
void *result = NULL;
6464

65-
hash = (const uint32_t *)oid->id;
66-
node = &cache->nodes[hash[0] & cache->size_mask];
65+
memcpy(&hash, oid->id, sizeof(hash));
66+
node = &cache->nodes[hash & cache->size_mask];
6767

6868
git_mutex_lock(&node->lock);
6969
{
@@ -79,13 +79,13 @@ void *git_cache_get(git_cache *cache, const git_oid *oid)
7979

8080
void *git_cache_try_store(git_cache *cache, void *entry)
8181
{
82-
const uint32_t *hash;
82+
uint32_t hash;
8383
const git_oid *oid;
8484
cache_node *node = NULL;
8585

8686
oid = &((git_cached_obj*)entry)->oid;
87-
hash = (const uint32_t *)oid->id;
88-
node = &cache->nodes[hash[0] & cache->size_mask];
87+
memcpy(&hash, oid->id, sizeof(hash));
88+
node = &cache->nodes[hash & cache->size_mask];
8989

9090
/* increase the refcount on this object, because
9191
* the cache now owns it */

src/commit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int git_commit_create(
169169
return error;
170170
}
171171

172-
int commit_parse_buffer(git_commit *commit, const void *data, size_t len)
172+
int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len)
173173
{
174174
const char *buffer = data;
175175
const char *buffer_end = (const char *)data + len;
@@ -236,7 +236,7 @@ int commit_parse_buffer(git_commit *commit, const void *data, size_t len)
236236
int git_commit__parse(git_commit *commit, git_odb_object *obj)
237237
{
238238
assert(commit);
239-
return commit_parse_buffer(commit, obj->raw.data, obj->raw.len);
239+
return git_commit__parse_buffer(commit, obj->raw.data, obj->raw.len);
240240
}
241241

242242
#define GIT_COMMIT_GETTER(_rvalue, _name, _return) \

src/commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ struct git_commit {
3030
void git_commit__free(git_commit *c);
3131
int git_commit__parse(git_commit *commit, git_odb_object *obj);
3232

33+
int git_commit__parse_buffer(git_commit *commit, const void *data, size_t len);
3334
#endif

src/config_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ static char *cfg_readline(diskfile_backend *cfg)
553553
/*
554554
* Consume a line, without storing it anywhere
555555
*/
556-
void cfg_consume_line(diskfile_backend *cfg)
556+
static void cfg_consume_line(diskfile_backend *cfg)
557557
{
558558
char *line_start, *line_end;
559559

src/mwindow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void git_mwindow_scan_lru(
113113
* Close the least recently used window. You should check to see if
114114
* the file descriptors need closing from time to time.
115115
*/
116-
int git_mwindow_close_lru(git_mwindow_file *mwf)
116+
static int git_mwindow_close_lru(git_mwindow_file *mwf)
117117
{
118118
unsigned int i;
119119
git_mwindow *lru_w = NULL, *lru_l = NULL;

src/odb_loose.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static int locate_object(char *object_location, loose_backend *backend, const gi
463463
}
464464

465465
/* Explore an entry of a directory and see if it matches a short oid */
466-
int fn_locate_object_short_oid(void *state, char *pathbuf) {
466+
static int fn_locate_object_short_oid(void *state, char *pathbuf) {
467467
loose_locate_object_state *sstate = (loose_locate_object_state *)state;
468468

469469
size_t pathbuf_len = strlen(pathbuf);
@@ -559,7 +559,7 @@ static int locate_object_short_oid(char *object_location, git_oid *res_oid, loos
559559
*
560560
***********************************************************/
561561

562-
int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
562+
static int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
563563
{
564564
char object_path[GIT_PATH_MAX];
565565
git_rawobj raw;
@@ -581,7 +581,7 @@ int loose_backend__read_header(size_t *len_p, git_otype *type_p, git_odb_backend
581581
return GIT_SUCCESS;
582582
}
583583

584-
int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
584+
static int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
585585
{
586586
char object_path[GIT_PATH_MAX];
587587
git_rawobj raw;
@@ -602,7 +602,7 @@ int loose_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_o
602602
return GIT_SUCCESS;
603603
}
604604

605-
int loose_backend__read_prefix(
605+
static int loose_backend__read_prefix(
606606
git_oid *out_oid,
607607
void **buffer_p,
608608
size_t *len_p,
@@ -643,7 +643,7 @@ int loose_backend__read_prefix(
643643
return GIT_SUCCESS;
644644
}
645645

646-
int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
646+
static int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
647647
{
648648
char object_path[GIT_PATH_MAX];
649649

@@ -652,7 +652,7 @@ int loose_backend__exists(git_odb_backend *backend, const git_oid *oid)
652652
return locate_object(object_path, (loose_backend *)backend, oid) == GIT_SUCCESS;
653653
}
654654

655-
int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
655+
static int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
656656
{
657657
loose_writestream *stream = (loose_writestream *)_stream;
658658
loose_backend *backend = (loose_backend *)_stream->backend;
@@ -673,13 +673,13 @@ int loose_backend__stream_fwrite(git_oid *oid, git_odb_stream *_stream)
673673
return git_filebuf_commit_at(&stream->fbuf, final_path);
674674
}
675675

676-
int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len)
676+
static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len)
677677
{
678678
loose_writestream *stream = (loose_writestream *)_stream;
679679
return git_filebuf_write(&stream->fbuf, data, len);
680680
}
681681

682-
void loose_backend__stream_free(git_odb_stream *_stream)
682+
static void loose_backend__stream_free(git_odb_stream *_stream)
683683
{
684684
loose_writestream *stream = (loose_writestream *)_stream;
685685

@@ -702,7 +702,7 @@ static int format_object_header(char *hdr, size_t n, size_t obj_len, git_otype o
702702
return len+1;
703703
}
704704

705-
int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type)
705+
static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, size_t length, git_otype type)
706706
{
707707
loose_backend *backend;
708708
loose_writestream *stream;
@@ -754,7 +754,7 @@ int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend
754754
return GIT_SUCCESS;
755755
}
756756

757-
int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
757+
static int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *data, size_t len, git_otype type)
758758
{
759759
int error, header_len;
760760
char final_path[GIT_PATH_MAX], header[64];
@@ -797,7 +797,7 @@ int loose_backend__write(git_oid *oid, git_odb_backend *_backend, const void *da
797797
return error;
798798
}
799799

800-
void loose_backend__free(git_odb_backend *_backend)
800+
static void loose_backend__free(git_odb_backend *_backend)
801801
{
802802
loose_backend *backend;
803803
assert(_backend);

src/odb_pack.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ int pack_backend__read_header(git_rawobj *obj, git_odb_backend *backend, const g
363363
}
364364
*/
365365

366-
int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
366+
static int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid)
367367
{
368368
struct git_pack_entry e;
369369
git_rawobj raw;
@@ -382,7 +382,7 @@ int pack_backend__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_od
382382
return GIT_SUCCESS;
383383
}
384384

385-
int pack_backend__read_prefix(
385+
static int pack_backend__read_prefix(
386386
git_oid *out_oid,
387387
void **buffer_p,
388388
size_t *len_p,
@@ -421,13 +421,13 @@ int pack_backend__read_prefix(
421421
return GIT_SUCCESS;
422422
}
423423

424-
int pack_backend__exists(git_odb_backend *backend, const git_oid *oid)
424+
static int pack_backend__exists(git_odb_backend *backend, const git_oid *oid)
425425
{
426426
struct git_pack_entry e;
427427
return pack_entry_find(&e, (struct pack_backend *)backend, oid) == GIT_SUCCESS;
428428
}
429429

430-
void pack_backend__free(git_odb_backend *_backend)
430+
static void pack_backend__free(git_odb_backend *_backend)
431431
{
432432
struct pack_backend *backend;
433433
size_t i;

src/refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ int git_reference_foreach(git_repository *repo, unsigned int list_flags, int (*c
15481548
return git_futils_direach(refs_path, GIT_PATH_MAX, _dirent_loose_listall, &data);
15491549
}
15501550

1551-
int cb__reflist_add(const char *ref, void *data)
1551+
static int cb__reflist_add(const char *ref, void *data)
15521552
{
15531553
return git_vector_insert((git_vector *)data, git__strdup(ref));
15541554
}

src/remote.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,6 @@ int git_remote_download(char **filename, git_remote *remote)
216216
return git_fetch_download_pack(filename, remote);
217217
}
218218

219-
git_headarray *git_remote_tips(git_remote *remote)
220-
{
221-
return &remote->refs;
222-
}
223-
224219
int git_remote_update_tips(struct git_remote *remote)
225220
{
226221
int error = GIT_SUCCESS;

0 commit comments

Comments
 (0)