Skip to content

Commit 574671b

Browse files
authored
Merge pull request libgit2#4534 from pks-t/pks/build-warnings
Fix build warnings
2 parents b8cb753 + 92324d8 commit 574671b

File tree

8 files changed

+18
-17
lines changed

8 files changed

+18
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ ELSE ()
218218

219219
ENABLE_WARNINGS(documentation)
220220
DISABLE_WARNINGS(missing-field-initializers)
221-
ENABLE_WARNINGS(strict-aliasing=2)
221+
ENABLE_WARNINGS(strict-aliasing)
222222
ENABLE_WARNINGS(strict-prototypes)
223223
ENABLE_WARNINGS(declaration-after-statement)
224224
DISABLE_WARNINGS(unused-const-variable)

src/index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2494,7 +2494,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
24942494

24952495
/* Parse all the entries */
24962496
for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) {
2497-
git_index_entry *entry;
2497+
git_index_entry *entry = NULL;
24982498
size_t entry_size = read_entry(&entry, index, buffer, buffer_size, last);
24992499

25002500
/* 0 bytes read means an object corruption */

src/patch_parse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ static int parse_hunk_body(
575575
switch (c) {
576576
case '\n':
577577
prefix = 0;
578+
/* fall through */
578579

579580
case ' ':
580581
origin = GIT_DIFF_LINE_CONTEXT;

src/revparse.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ int revparse__ext(
770770
}
771771

772772
case '@':
773-
{
774773
if (spec[pos+1] == '{') {
775774
git_object *temp_object = NULL;
776775

@@ -786,10 +785,8 @@ int revparse__ext(
786785
if (temp_object != NULL)
787786
base_rev = temp_object;
788787
break;
789-
} else {
790-
/* Fall through */
791788
}
792-
}
789+
/* fall through */
793790

794791
default:
795792
if ((error = ensure_left_hand_identifier_is_not_known_yet(base_rev, reference)) < 0)

src/streams/openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
344344
GENERAL_NAMES *alts;
345345
struct in6_addr addr6;
346346
struct in_addr addr4;
347-
void *addr;
347+
void *addr = NULL;
348348
int i = -1, j, error = 0;
349349

350350
if (SSL_get_verify_result(ssl) != X509_V_OK) {
@@ -357,7 +357,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
357357
type = GEN_IPADD;
358358
addr = &addr4;
359359
} else {
360-
if(p_inet_pton(AF_INET6, host, &addr6)) {
360+
if (p_inet_pton(AF_INET6, host, &addr6)) {
361361
type = GEN_IPADD;
362362
addr = &addr6;
363363
}
@@ -397,7 +397,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
397397
matched = 1;
398398
} else if (type == GEN_IPADD) {
399399
/* Here name isn't so much a name but a binary representation of the IP */
400-
matched = !!memcmp(name, addr, namelen);
400+
matched = addr && !!memcmp(name, addr, namelen);
401401
}
402402
}
403403
}

src/tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ int git_tree_entry_bypath(
957957
* walking down the path */
958958
if (path[filename_len + 1] != '\0')
959959
break;
960-
960+
/* fall through */
961961
case '\0':
962962
/* If there are no more components in the path, return
963963
* this entry */

src/util.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
#include "util.h"
99

10-
#include "git2.h"
11-
#include <stdio.h>
12-
#include <ctype.h>
13-
#include "posix.h"
10+
#include "common.h"
1411

1512
#ifdef GIT_WIN32
1613
# include "win32/w32_buffer.h"
@@ -478,9 +475,11 @@ uint32_t git__hash(const void *key, int len, uint32_t seed)
478475

479476
switch(len & 3) {
480477
case 3: k1 ^= tail[2] << 16;
478+
/* fall through */
481479
case 2: k1 ^= tail[1] << 8;
480+
/* fall through */
482481
case 1: k1 ^= tail[0];
483-
MURMUR_BLOCK();
482+
MURMUR_BLOCK();
484483
}
485484

486485
h1 ^= len;

src/util.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99

1010
#include "common.h"
1111

12+
#ifndef GIT_WIN32
13+
# include <ctype.h>
14+
#endif
15+
1216
#include "git2/buffer.h"
13-
#include "buffer.h"
14-
#include "thread-utils.h"
1517

18+
#include "buffer.h"
1619
#include "common.h"
1720
#include "strnlen.h"
21+
#include "thread-utils.h"
1822

1923
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
2024
#define bitsizeof(x) (CHAR_BIT * sizeof(x))

0 commit comments

Comments
 (0)