Commit b6ac07b51771641f3ae994c17f361fbd8bec36ef

Russell Belfer 2013-08-22T14:45:10

Trying to fix Win32 warnings

diff --git a/src/cc-compat.h b/src/cc-compat.h
index a5e4ce1..37f1ea8 100644
--- a/src/cc-compat.h
+++ b/src/cc-compat.h
@@ -54,8 +54,12 @@
 
 #if defined (_MSC_VER)
 	typedef unsigned char bool;
-#	define true 1
-#	define false 0
+#	ifndef true
+#		define true 1
+#	endif
+#	ifndef false
+#		define false 0
+#	endif
 #else
 #	include <stdbool.h>
 #endif
diff --git a/src/diff_tform.c b/src/diff_tform.c
index ba35d3c..6b8cf44 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -859,9 +859,9 @@ find_best_matches:
 				}
 
 				/* write new mapping */
-				tgt2src[t].idx = s;
+				tgt2src[t].idx = (uint32_t)s;
 				tgt2src[t].similarity = (uint32_t)similarity;
-				src2tgt[s].idx = t;
+				src2tgt[s].idx = (uint32_t)t;
 				src2tgt[s].similarity = (uint32_t)similarity;
 			}
 
@@ -869,7 +869,7 @@ find_best_matches:
 			if (tgt2src_copy != NULL &&
 				tgt2src_copy[t].similarity < (uint32_t)similarity)
 			{
-				tgt2src_copy[t].idx = s;
+				tgt2src_copy[t].idx = (uint32_t)s;
 				tgt2src_copy[t].similarity = (uint32_t)similarity;
 			}
 
diff --git a/src/sortedcache.c b/src/sortedcache.c
index 16dd6a7..33171c4 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -271,7 +271,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
 	itemlen = sc->item_path_offset + keylen + 1;
 	itemlen = (itemlen + 7) & ~7;
 
-	if ((item = git_pool_mallocz(&sc->pool, itemlen)) == NULL) {
+	if ((item = git_pool_mallocz(&sc->pool, (uint32_t)itemlen)) == NULL) {
 		/* don't use GITERR_CHECK_ALLOC b/c of lock */
 		error = -1;
 		goto done;
diff --git a/src/win32/pthread.h b/src/win32/pthread.h
index 54e5286..50d8362 100644
--- a/src/win32/pthread.h
+++ b/src/win32/pthread.h
@@ -30,15 +30,16 @@ typedef SRWLOCK pthread_rwlock_t;
 #define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT
 
 int pthread_create(
-	pthread_t *GIT_RESTRICT,
-	const pthread_attr_t *GIT_RESTRICT,
+	pthread_t *GIT_RESTRICT thread,
+	const pthread_attr_t *GIT_RESTRICT attr,
 	void *(*start_routine)(void*),
-	void *__restrict);
+	void *GIT_RESTRICT arg);
 
 int pthread_join(pthread_t, void **);
 
 int pthread_mutex_init(
-	pthread_mutex_t *GIT_RESTRICT, const pthread_mutexattr_t *GIT_RESTRICT);
+	pthread_mutex_t *GIT_RESTRICT mutex,
+	const pthread_mutexattr_t *GIT_RESTRICT mutexattr);
 int pthread_mutex_destroy(pthread_mutex_t *);
 int pthread_mutex_lock(pthread_mutex_t *);
 int pthread_mutex_unlock(pthread_mutex_t *);
@@ -52,7 +53,8 @@ int pthread_cond_signal(pthread_cond_t *);
 int pthread_num_processors_np(void);
 
 int pthread_rwlock_init(
-	pthread_rwlock_t *GIT_RESTRICT, const pthread_rwlockattr_t *GIT_RESTRICT);
+	pthread_rwlock_t *GIT_RESTRICT lock,
+	const pthread_rwlockattr_t *GIT_RESTRICT attr);
 int pthread_rwlock_rdlock(pthread_rwlock_t *);
 int pthread_rwlock_rdunlock(pthread_rwlock_t *);
 int pthread_rwlock_wrlock(pthread_rwlock_t *);
diff --git a/tests-clar/stress/diff.c b/tests-clar/stress/diff.c
index 62ccd5e..0524aa1 100644
--- a/tests-clar/stress/diff.c
+++ b/tests-clar/stress/diff.c
@@ -15,7 +15,7 @@ void test_stress_diff__cleanup(void)
 #define ANOTHER_POEM \
 "OH, glorious are the guarded heights\nWhere guardian souls abide—\nSelf-exiled from our gross delights—\nAbove, beyond, outside:\nAn ampler arc their spirit swings—\nCommands a juster view—\nWe have their word for all these things,\nNo doubt their words are true.\n\nYet we, the bond slaves of our day,\nWhom dirt and danger press—\nCo-heirs of insolence, delay,\nAnd leagued unfaithfulness—\nSuch is our need must seek indeed\nAnd, having found, engage\nThe men who merely do the work\nFor which they draw the wage.\n\nFrom forge and farm and mine and bench,\nDeck, altar, outpost lone—\nMill, school, battalion, counter, trench,\nRail, senate, sheepfold, throne—\nCreation's cry goes up on high\nFrom age to cheated age:\n\"Send us the men who do the work\n\"For which they draw the wage!\"\n"
 
-static void test_with_many(size_t expected_new)
+static void test_with_many(int expected_new)
 {
 	git_index *index;
 	git_tree *tree, *new_tree;