From 9e3aa94764b1c686ee5848b6f5bf1821c354a759 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 8 Jun 2011 20:39:38 +0200 Subject: [PATCH 1/3] Fix compilation warnings in MSVC --- src/fileops.c | 5 +++-- src/msvc-compat.h | 2 -- tests/t09-tree.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/fileops.c b/src/fileops.c index 2a78764c6..c8c37bee7 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 2343ea849..89f410d4b 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 af992fdb3..8062d53b2 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); From 95818ff73aa8af414c4c893a5088656ac07a6de4 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 8 Jun 2011 22:15:49 +0200 Subject: [PATCH 2/3] Fix filebuf0 test which was failing on Windows --- tests/t00-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/t00-core.c b/tests/t00-core.c index 5cd4025d3..1358cc6c0 100644 --- a/tests/t00-core.c +++ b/tests/t00-core.c @@ -664,9 +664,12 @@ END_TEST BEGIN_TEST(filebuf0, "make sure git_filebuf_open doesn't delete an existing lock") git_filebuf file; + int fd; char test[] = "test", testlock[] = "test.lock"; - must_pass(gitfo_creat(testlock, 0744)); + fd = gitfo_creat(testlock, 0744); + must_pass(fd); + must_pass(gitfo_close(fd)); must_fail(git_filebuf_open(&file, test, 0)); must_pass(gitfo_exists(testlock)); must_pass(gitfo_unlink(testlock)); From 63fadf99dccf51cf6f7912419690dd5af128a66a Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 15 Jun 2011 17:04:11 +0200 Subject: [PATCH 3/3] Add mode_t definition in MSVC compat layer --- src/fileops.c | 2 +- src/msvc-compat.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fileops.c b/src/fileops.c index c8c37bee7..2a20617a5 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 = (unsigned short)fMode; + buf->st_mode = (mode_t)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)); diff --git a/src/msvc-compat.h b/src/msvc-compat.h index 89f410d4b..df3e62d11 100644 --- a/src/msvc-compat.h +++ b/src/msvc-compat.h @@ -21,6 +21,8 @@ # define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO) # define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK) +# define mode_t unsigned short + /* case-insensitive string comparison */ # define strcasecmp _stricmp # define strncasecmp _strnicmp