From: Frank Li <lznuaa@gmail.com>
To: git@vger.kernel.org, msysgit@googlegroups.com
Cc: Frank Li <lznuaa@gmail.com>
Subject: [PATCH 01/12] Avoid declaration after instruction
Date: Wed, 19 Aug 2009 23:52:36 +0800 [thread overview]
Message-ID: <1250697167-5536-1-git-send-email-lznuaa@gmail.com> (raw)
Microsoft Visual C++ does not understand this C99 style
Signed-off-by: Frank Li <lznuaa@gmail.com>
---
compat/mingw.c | 16 ++++++++++++----
help.c | 3 ++-
run-command.c | 2 ++
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index bed4178..75c74b1 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...)
{
va_list args;
unsigned mode;
+ int fd;
+
va_start(args, oflags);
mode = va_arg(args, int);
va_end(args);
if (!strcmp(filename, "/dev/null"))
filename = "nul";
- int fd = open(filename, oflags, mode);
+
+ fd = open(filename, oflags, mode);
+
if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
DWORD attrs = GetFileAttributes(filename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
@@ -580,10 +584,11 @@ static char **get_path_split(void)
static void free_path_split(char **path)
{
+ char **p = path;
+
if (!path)
return;
- char **p = path;
while (*p)
free(*p++);
free(path);
@@ -1108,9 +1113,11 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
#undef signal
sig_handler_t mingw_signal(int sig, sig_handler_t handler)
{
+ sig_handler_t old;
+
if (sig != SIGALRM)
return signal(sig, handler);
- sig_handler_t old = timer_fn;
+ old = timer_fn;
timer_fn = handler;
return old;
}
@@ -1197,8 +1204,9 @@ struct dirent *mingw_readdir(DIR *dir)
if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
{
+ DWORD lasterr;
handle = FindFirstFileA(dir->dd_name, &buf);
- DWORD lasterr = GetLastError();
+ lasterr = GetLastError();
dir->dd_handle = (long)handle;
if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
errno = err_win_to_posix(lasterr);
diff --git a/help.c b/help.c
index 6c46d8b..399b0b4 100644
--- a/help.c
+++ b/help.c
@@ -127,7 +127,7 @@ static int is_executable(const char *name)
return 0;
#ifdef __MINGW32__
- /* cannot trust the executable bit, peek into the file instead */
+{ /* cannot trust the executable bit, peek into the file instead */
char buf[3] = { 0 };
int n;
int fd = open(name, O_RDONLY);
@@ -140,6 +140,7 @@ static int is_executable(const char *name)
st.st_mode |= S_IXUSR;
close(fd);
}
+}
#endif
return st.st_mode & S_IXUSR;
}
diff --git a/run-command.c b/run-command.c
index ff3d8e2..d1df7ab 100644
--- a/run-command.c
+++ b/run-command.c
@@ -123,6 +123,7 @@ int start_command(struct child_process *cmd)
exit(127);
}
#else
+{
int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
const char **sargv = cmd->argv;
char **env = environ;
@@ -186,6 +187,7 @@ int start_command(struct child_process *cmd)
dup2(s1, 1), close(s1);
if (s2 >= 0)
dup2(s2, 2), close(s2);
+}
#endif
if (cmd->pid < 0) {
--
1.6.4.msysgit.0
next reply other threads:[~2009-08-19 15:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 15:52 Frank Li [this message]
2009-08-19 15:52 ` [PATCH 02/12] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Frank Li
2009-08-19 15:52 ` [PATCH 03/12] Using macro WIN32 replace __MINGW32_ at Windows special handler The code which is conditional on MinGW32 is actually conditional on Windows. Use WIN32 macro will share both MINGW32 and MSVC environment Frank Li
2009-08-19 15:52 ` [PATCH 04/12] mingw.c: Use the O_BINARY flag to open files Frank Li
2009-08-19 15:52 ` [PATCH 05/12] Place __stdcall between return value and function name Frank Li
2009-08-19 15:52 ` [PATCH 06/12] Add _MSC_VER in porting head file git-compat-util.h Frank Li
2009-08-19 15:52 ` [PATCH 07/12] Add Unix header files to build git at MSVC Frank Li
2009-08-19 15:52 ` [PATCH 08/12] Add MSVC porting files Frank Li
2009-08-19 15:52 ` [PATCH 09/12] Don't include windows.h at winansi.c at MSVC build Frank Li
2009-08-19 15:52 ` [PATCH 10/12] Fix errcode have defined as int at MSVC Frank Li
2009-08-19 15:52 ` [PATCH 11/12] Add MSVC Project file Frank Li
2009-08-19 15:59 ` [PATCH 08/12] Add MSVC porting files Erik Faye-Lund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1250697167-5536-1-git-send-email-lznuaa@gmail.com \
--to=lznuaa@gmail.com \
--cc=git@vger.kernel.org \
--cc=msysgit@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).