Fix compilation warnings in MSVC
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
diff --git a/src/fileops.c b/src/fileops.c
index 2a78764..c8c37be 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -633,7 +633,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
buf->st_gid = 0;
buf->st_uid = 0;
buf->st_nlink = 1;
- buf->st_mode = fMode;
+ buf->st_mode = (unsigned short)fMode;
buf->st_size = fdata.nFileSizeLow; /* Can't use nFileSizeHigh, since it's not a stat64 */
buf->st_dev = buf->st_rdev = (_getdrive() - 1);
buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
@@ -686,6 +686,7 @@ int gitfo_lstat__w32(const char *file_name, struct stat *buf)
alt_name[namelen] = 0;
return do_lstat(alt_name, buf);
}
+
int gitfo_readlink__w32(const char *link, char *target, size_t target_len)
{
HANDLE hFile;
@@ -711,7 +712,7 @@ int gitfo_readlink__w32(const char *link, char *target, size_t target_len)
if (dwRet > 4) {
/* Skip first 4 characters if they are "\\?\" */
if (target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') {
- char tmp[MAXPATHLEN];
+ char tmp[GIT_PATH_MAX];
unsigned int offset = 4;
dwRet -= 4;
diff --git a/src/msvc-compat.h b/src/msvc-compat.h
index 2343ea8..89f410d 100644
--- a/src/msvc-compat.h
+++ b/src/msvc-compat.h
@@ -21,8 +21,6 @@
# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
-# define MAXPATHLEN MAX_PATH
-
/* case-insensitive string comparison */
# define strcasecmp _stricmp
# define strncasecmp _strnicmp
diff --git a/tests/t09-tree.c b/tests/t09-tree.c
index af992fd..8062d53 100644
--- a/tests/t09-tree.c
+++ b/tests/t09-tree.c
@@ -81,7 +81,7 @@ BEGIN_TEST(read0, "acces randomly the entries on a loaded tree")
must_be_true(git_tree_entry_byindex(tree, 0) != NULL);
must_be_true(git_tree_entry_byindex(tree, 2) != NULL);
must_be_true(git_tree_entry_byindex(tree, 3) == NULL);
- must_be_true(git_tree_entry_byindex(tree, -1) == NULL);
+ must_be_true(git_tree_entry_byindex(tree, (unsigned int)-1) == NULL);
git_tree_close(tree);
git_repository_free(repo);