Commit 6c8b458dccec1a4c81825d9c0777232540abac06

Vicent Marti 2011-09-29T17:04:45

mingw: Fix compilation warnings

diff --git a/src/cc-compat.h b/src/cc-compat.h
index 78dfba7..cce4ca9 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -65,13 +65,6 @@
 # define PRIuZ "zu"
 #endif
 
-/* Define the printf format for 64 bit types */
-#if defined(__MINGW32__)
-#	define PRIdMAX "I64d"
-#else
-#	define PRIdMAX "lld"
-#endif
-
 /* Micosoft Visual C/C++ */
 #if defined(_MSC_VER)
 /* disable "deprecated function" warnings */
diff --git a/src/config.c b/src/config.c
index 852c2e1..c4f3807 100644
--- a/src/config.c
+++ b/src/config.c
@@ -167,7 +167,7 @@ int git_config_delete(git_config *cfg, const char *name)
 int git_config_set_long(git_config *cfg, const char *name, long long value)
 {
 	char str_value[32]; /* All numbers should fit in here */
-	p_snprintf(str_value, sizeof(str_value), "%" PRIdMAX, value);
+	p_snprintf(str_value, sizeof(str_value), "%" PRId64, value);
 	return git_config_set_string(cfg, name, str_value);
 }
 
diff --git a/src/refs.c b/src/refs.c
index 3711759..0acfc19 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -421,6 +421,7 @@ static int packed_parse_oid(
 		const char **buffer_out,
 		const char *buffer_end)
 {
+	git_reference *_ref = NULL;
 	reference_oid *ref = NULL;
 
 	const char *buffer = *buffer_out;
@@ -456,10 +457,12 @@ static int packed_parse_oid(
 	if (refname[refname_len - 1] == '\r')
 		refname[refname_len - 1] = 0;
 
-	error = reference_create((git_reference **)&ref, repo, refname, GIT_REF_OID);
+	error = reference_create(&_ref, repo, refname, GIT_REF_OID);
 	if (error < GIT_SUCCESS)
 		goto cleanup;
 
+	ref = (reference_oid *)_ref;
+
 	git_oid_cpy(&ref->oid, &id);
 	ref->ref.type |= GIT_REF_PACKED;
 
@@ -597,7 +600,8 @@ static int _dirent_loose_listall(void *_data, char *full_path)
 static int _dirent_loose_load(void *data, char *full_path)
 {
 	git_repository *repository = (git_repository *)data;
-	git_reference *reference, *old_ref;
+	git_reference *reference;
+	void *old_ref = NULL;
 	char *file_path;
 	int error;
 
@@ -609,13 +613,13 @@ static int _dirent_loose_load(void *data, char *full_path)
 	if (error == GIT_SUCCESS && reference != NULL) {
 		reference->type |= GIT_REF_PACKED;
 
-		if (git_hashtable_insert2(repository->references.packfile, reference->name, reference, (void **)&old_ref) < GIT_SUCCESS) {
+		if (git_hashtable_insert2(repository->references.packfile, reference->name, reference, &old_ref) < GIT_SUCCESS) {
 			reference_free(reference);
 			return GIT_ENOMEM;
 		}
 
 		if (old_ref != NULL)
-			reference_free(old_ref);
+			reference_free((git_reference *)old_ref);
 	}
 
 	return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to load loose dirent");
@@ -1043,7 +1047,8 @@ int git_reference_create_symbolic(git_reference **ref_out, git_repository *repo,
 {
 	char normalized[GIT_REFNAME_MAX];
 	int error = GIT_SUCCESS, updated = 0;
-	git_reference *ref = NULL, *old_ref = NULL;
+	git_reference *ref = NULL;
+	void *old_ref = NULL;
 
 	if (git_reference_lookup(&ref, repo, name) == GIT_SUCCESS && !force)
 		return git__throw(GIT_EEXISTS, "Failed to create symbolic reference. Reference already exists");
@@ -1079,12 +1084,12 @@ int git_reference_create_symbolic(git_reference **ref_out, git_repository *repo,
 	 * it in the loose cache. If we replaced a ref, free it.
 	 */
 	if (!updated){
-		error = git_hashtable_insert2(repo->references.loose_cache, ref->name, ref, (void **) &old_ref);
+		error = git_hashtable_insert2(repo->references.loose_cache, ref->name, ref, &old_ref);
 		if (error < GIT_SUCCESS)
 			goto cleanup;
 
-		if(old_ref)
-			reference_free(old_ref);
+		if (old_ref != NULL)
+			reference_free((git_reference *)old_ref);
 	}
 
 	*ref_out = ref;
@@ -1099,7 +1104,8 @@ cleanup:
 int git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force)
 {
 	int error = GIT_SUCCESS, updated = 0;
-	git_reference *ref = NULL, *old_ref = NULL;
+	git_reference *ref = NULL;
+	void *old_ref = NULL;
 
 	if(git_reference_lookup(&ref, repo, name) == GIT_SUCCESS && !force)
 		return git__throw(GIT_EEXISTS, "Failed to create reference OID. Reference already exists");
@@ -1129,12 +1135,12 @@ int git_reference_create_oid(git_reference **ref_out, git_repository *repo, cons
 		goto cleanup;
 
 	if(!updated){
-		error = git_hashtable_insert2(repo->references.loose_cache, ref->name, ref, (void **) &old_ref);
+		error = git_hashtable_insert2(repo->references.loose_cache, ref->name, ref, &old_ref);
 		if (error < GIT_SUCCESS)
 			goto cleanup;
 
-		if(old_ref)
-			reference_free(old_ref);
+		if (old_ref != NULL)
+			reference_free((git_reference *)old_ref);
 	}
 
 	*ref_out = ref;
@@ -1269,7 +1275,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
 	const char *target_ref = NULL;
 	const char *head_target = NULL;
 	const git_oid *target_oid = NULL;
-	git_reference *new_ref = NULL, *old_ref = NULL, *head = NULL;
+	git_reference *new_ref = NULL, *head = NULL;
 
 	assert(ref);
 
@@ -1385,7 +1391,7 @@ int git_reference_rename(git_reference *ref, const char *new_name, int force)
 	new_ref->name = NULL;
 	reference_free(new_ref);
 
-	if ((error = git_hashtable_insert2(ref->owner->references.loose_cache, ref->name, ref, (void **)&old_ref)) < GIT_SUCCESS)
+	if ((error = git_hashtable_insert2(ref->owner->references.loose_cache, ref->name, ref, NULL)) < GIT_SUCCESS)
 		goto rollback;
 
 	/*
diff --git a/src/win32/posix.h b/src/win32/posix.h
index d82506a..6d78322 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -11,6 +11,9 @@
 #include "fnmatch.h"
 #include "utf8-conv.h"
 
+/* Define the printf format for 64 bit types */
+#define PRId64 "I64d"
+
 GIT_INLINE(int) p_link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new))
 {
 	GIT_UNUSED_ARG(old)
@@ -44,5 +47,9 @@ extern int p_chdir(const char* path);
 extern int p_chmod(const char* path, int mode);
 extern int p_rmdir(const char* path);
 extern int p_access(const char* path, int mode);
+extern int p_fsync(int fd);
+extern int p_open(const char *path, int flags);
+extern int p_creat(const char *path, int mode);
+extern int p_getcwd(char *buffer_out, size_t size);
 
 #endif