From: Frank Li <lznuaa@gmail.com>
To: git@vger.kernel.org, msysgit@googlegroups.com
Cc: Johannes.Schindelin@gmx.de, Frank Li <lznuaa@gmail.com>
Subject: [PATCH 02/11] Fix declare variable at mid of function
Date: Tue, 18 Aug 2009 00:01:03 +0800 [thread overview]
Message-ID: <1250524872-5148-2-git-send-email-lznuaa@gmail.com> (raw)
In-Reply-To: <1250524872-5148-1-git-send-email-lznuaa@gmail.com>
Some compiler such as MSVC can't support declear variable at mid of funtion at c file.
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 prev parent reply other threads:[~2009-08-17 16:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-17 16:01 [PATCH 01/11] Fix build failure at VC because function declare use old style at regex.c Frank Li
2009-08-17 16:01 ` Frank Li [this message]
2009-08-17 16:01 ` [PATCH 03/11] Define SNPRINTF_SIZE_CORR 1 when use MSVC build git Frank Li
2009-08-17 16:01 ` [PATCH 04/11] Add _MSC_VER predefine macro to make same behaviors with __MINGW32__ Enable MSVC build. MSVC have the save behaviors with msysgit Frank Li
2009-08-17 16:38 ` Johannes Schindelin
2009-08-18 1:29 ` Frank Li
2009-08-18 5:06 ` tom fogal
2009-08-17 16:32 ` [PATCH 03/11] Define SNPRINTF_SIZE_CORR 1 when use MSVC build git Johannes Schindelin
2009-08-18 1:19 ` Frank Li
2009-08-18 9:31 ` Johannes Schindelin
2009-08-17 16:29 ` [PATCH 02/11] Fix declare variable at mid of function Johannes Schindelin
2009-08-17 16:34 ` Reece Dunn
2009-08-17 19:36 ` Johannes Schindelin
2009-08-18 5:23 ` [msysGit] " Marius Storm-Olsen
2009-08-18 9:34 ` Johannes Schindelin
2009-08-18 16:11 ` Frank Li
2009-08-18 16:52 ` Matthieu Moy
2009-08-19 10:15 ` Johannes Schindelin
2009-08-19 10:55 ` Johannes Sixt
2009-08-19 13:15 ` Johannes Schindelin
2009-08-19 15:21 ` [msysGit] " Johannes Sixt
2009-08-17 19:28 ` Junio C Hamano
2009-08-17 21:00 ` [msysGit] " Johannes Schindelin
2009-08-17 21:38 ` Junio C Hamano
2009-08-17 16:26 ` [PATCH 01/11] Fix build failure at VC because function declare use old style at regex.c Johannes Schindelin
2009-08-18 15:03 ` Frank Li
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=1250524872-5148-2-git-send-email-lznuaa@gmail.com \
--to=lznuaa@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--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).