summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2014-10-13 13:34:15 -0400
committerEdward Thomson <ethomson@microsoft.com>2014-10-26 22:13:40 -0400
commit369b0217330383925d8091ae01079789cde80598 (patch)
treee3c14a87d6b43bf0a589ce8cd6dba09501040a7c
parent70f7e2c6e3fc908dd6a4e027dc43d5ce5be94d75 (diff)
downloadlibgit2-369b0217330383925d8091ae01079789cde80598.tar.gz
Clean up various compiler warnings
-rw-r--r--src/describe.c5
-rw-r--r--src/thread-utils.h6
-rw-r--r--src/transaction.c6
-rw-r--r--src/transports/http.c7
-rw-r--r--src/transports/ssh.c7
5 files changed, 20 insertions, 11 deletions
diff --git a/src/describe.c b/src/describe.c
index 9b41316fe..fb39c58fe 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 8deedce81..dd1136caf 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 ebb943cea..1a4fffb36 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 bcfeaee7f..4070b683a 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 3868a529a..39e4e3d15 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");