Clean up various compiler warnings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
diff --git a/src/describe.c b/src/describe.c
index 9b41316..fb39c58 100644
--- a/src/describe.c
+++ b/src/describe.c
@@ -397,7 +397,7 @@ static int show_suffix(
const git_oid* id,
size_t abbrev_size)
{
- int error, size;
+ int error, size = 0;
char hex_oid[GIT_OID_HEXSZ];
@@ -818,7 +818,8 @@ int git_describe_format(git_buf *out, const git_describe_result *result, const g
/* If we didn't find *any* tags, we fall back to the commit's id */
if (result->fallback_to_id) {
char hex_oid[GIT_OID_HEXSZ + 1] = {0};
- int size;
+ int size = 0;
+
if ((error = find_unique_abbrev_size(
&size, repo, &result->commit_id, opts.abbreviated_size)) < 0)
return -1;
diff --git a/src/thread-utils.h b/src/thread-utils.h
index 8deedce..dd1136c 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -183,8 +183,10 @@ GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
/* Pthreads Mutex */
#define git_mutex unsigned int
-static int git_mutex_init(git_mutex* mutex) { GIT_UNUSED(mutex); return 0; }
-static int git_mutex_lock(git_mutex* mutex) { GIT_UNUSED(mutex); return 0; }
+GIT_INLINE(int) git_mutex_init(git_mutex *mutex) \
+ { GIT_UNUSED(mutex); return 0; }
+GIT_INLINE(int) git_mutex_lock(git_mutex *mutex) \
+ { GIT_UNUSED(mutex); return 0; }
#define git_mutex_unlock(a) (void)0
#define git_mutex_free(a) (void)0
diff --git a/src/transaction.c b/src/transaction.c
index ebb943c..1a4fffb 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -274,7 +274,7 @@ static int update_target(git_refdb *db, transaction_node *node)
} else if (node->ref_type == GIT_REF_SYMBOLIC) {
ref = git_reference__alloc_symbolic(node->name, node->target.symbolic);
} else {
- assert(0);
+ abort();
}
GITERR_CHECK_ALLOC(ref);
@@ -287,7 +287,7 @@ static int update_target(git_refdb *db, transaction_node *node)
} else if (node->ref_type == GIT_REF_SYMBOLIC) {
error = git_refdb_unlock(db, node->payload, true, update_reflog, ref, node->sig, node->message);
} else {
- assert(0);
+ abort();
}
git_reference_free(ref);
@@ -300,7 +300,7 @@ int git_transaction_commit(git_transaction *tx)
{
transaction_node *node;
git_strmap_iter pos;
- int error;
+ int error = 0;
assert(tx);
diff --git a/src/transports/http.c b/src/transports/http.c
index bcfeaee..4070b68 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -552,7 +552,7 @@ static int http_connect(http_subtransport *t)
#ifdef GIT_SSL
if ((!error || error == GIT_ECERTIFICATE) && t->owner->certificate_check_cb != NULL) {
X509 *cert = SSL_get_peer_certificate(t->socket.ssl.ssl);
- git_cert_x509 cert_info;
+ git_cert_x509 cert_info, *cert_info_ptr;
int len, is_valid;
unsigned char *guard, *encoded_cert;
@@ -581,7 +581,10 @@ static int http_connect(http_subtransport *t)
cert_info.cert_type = GIT_CERT_X509;
cert_info.data = encoded_cert;
cert_info.len = len;
- error = t->owner->certificate_check_cb((git_cert *) &cert_info, is_valid, t->connection_data.host, t->owner->message_cb_payload);
+
+ cert_info_ptr = &cert_info;
+
+ error = t->owner->certificate_check_cb((git_cert *) cert_info_ptr, is_valid, t->connection_data.host, t->owner->message_cb_payload);
git__free(encoded_cert);
if (error < 0) {
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 3868a52..39e4e3d 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -480,7 +480,7 @@ static int _git_ssh_setup_conn(
goto on_error;
if (t->owner->certificate_check_cb != NULL) {
- git_cert_hostkey cert = { 0 };
+ git_cert_hostkey cert = { 0 }, *cert_ptr;
const char *key;
cert.cert_type = GIT_CERT_HOSTKEY_LIBSSH2;
@@ -504,7 +504,10 @@ static int _git_ssh_setup_conn(
/* We don't currently trust any hostkeys */
giterr_clear();
- error = t->owner->certificate_check_cb((git_cert *) &cert, 0, host, t->owner->message_cb_payload);
+
+ cert_ptr = &cert;
+
+ error = t->owner->certificate_check_cb((git_cert *) cert_ptr, 0, host, t->owner->message_cb_payload);
if (error < 0) {
if (!giterr_last())
giterr_set(GITERR_NET, "user cancelled hostkey check");