git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Marius Storm-Olsen <mstormo@gmail.com>
To: Johannes.Schindelin@gmx.de
Cc: msysgit@googlegroups.com, git@vger.kernel.org, lznuaa@gmail.com,
	Marius Storm-Olsen <mstormo@gmail.com>
Subject: [PATCH 02/14] Avoid declaration after statement
Date: Fri, 21 Aug 2009 15:30:34 +0200	[thread overview]
Message-ID: <af66de324093bbe8f500b1ef20689dd5d355abf4.1250860247.git.mstormo@gmail.com> (raw)
In-Reply-To: <6283b3e1775f43c6fc07e5047f9c99acdc27bc8f.1250860247.git.mstormo@gmail.com>
In-Reply-To: <cover.1250860247.git.mstormo@gmail.com>

From: Frank Li <lznuaa@gmail.com>

Microsoft Visual C++ does not understand this C99 style

Signed-off-by: Frank Li <lznuaa@gmail.com>
Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com>
---
 compat/mingw.c |   14 ++++++++++----
 help.c         |    3 ++-
 run-command.c  |    2 ++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index bed4178..e4e0e60 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,9 @@ 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 = timer_fn;
 	if (sig != SIGALRM)
 		return signal(sig, handler);
-	sig_handler_t old = timer_fn;
 	timer_fn = handler;
 	return old;
 }
@@ -1197,8 +1202,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 294337e..fd51b8e 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 f3e7abb..efac7ad 100644
--- a/run-command.c
+++ b/run-command.c
@@ -134,6 +134,7 @@ fail_pipe:
 		error("cannot fork() for %s: %s", cmd->argv[0],
 			strerror(failed_errno = errno));
 #else
+{
 	int s0 = -1, s1 = -1, s2 = -1;	/* backups of stdin, stdout, stderr */
 	const char **sargv = cmd->argv;
 	char **env = environ;
@@ -200,6 +201,7 @@ fail_pipe:
 		dup2(s1, 1), close(s1);
 	if (s2 >= 0)
 		dup2(s2, 2), close(s2);
+}
 #endif
 
 	if (cmd->pid < 0) {
-- 
1.6.3.msysgit.0.18.gef407

  reply	other threads:[~2009-08-21 13:31 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-21 13:30 [RFC/PATCH 00/14] Build git with MSVC Marius Storm-Olsen
2009-08-21 13:30 ` [PATCH 01/14] Fix non-constant array creation Marius Storm-Olsen
2009-08-21 13:30   ` Marius Storm-Olsen [this message]
2009-08-21 13:30     ` [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Marius Storm-Olsen
2009-08-21 13:30       ` [PATCH 04/14] Add define guards to compat/win32.h Marius Storm-Olsen
2009-08-21 13:30         ` [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89) Marius Storm-Olsen
2009-08-21 13:30           ` [PATCH 06/14] mingw.c: Use the O_BINARY flag to open files Marius Storm-Olsen
2009-08-21 13:30             ` [PATCH 07/14] Fix __stdcall/WINAPI placement and function prototype Marius Storm-Olsen
2009-08-21 13:30               ` [PATCH 08/14] Test for WIN32 instead of __MINGW32_ Marius Storm-Olsen
2009-08-21 13:30                 ` [PATCH 09/14] Avoid including windows.h in winansi.c for MSVC build Marius Storm-Olsen
2009-08-21 13:30                   ` [PATCH 10/14] Add empty header files for MSVC port Marius Storm-Olsen
2009-08-21 13:30                     ` [PATCH 11/14] Add MinGW header files to build git with MSVC Marius Storm-Olsen
2009-08-21 13:30                       ` [PATCH 12/14] Add platform files for MSVC porting Marius Storm-Olsen
2009-08-21 13:30                         ` [PATCH 13/14] Add MSVC project files Marius Storm-Olsen
2009-08-21 13:30                           ` [PATCH 14/14] Add README and gitignore file for MSVC build Marius Storm-Olsen
2009-08-23 16:26                             ` Thiago Farina
2009-08-23 18:22                               ` Reece Dunn
2009-08-23 18:59                                 ` Marius Storm-Olsen
2009-08-23 19:29                                   ` Thiago Farina
2009-08-24  7:03                                     ` [msysGit] " Marius Storm-Olsen
2009-08-25 14:32                                     ` Frank Li
2009-08-25 17:24                                       ` Thiago Farina
2009-08-27 13:16                                         ` Frank Li
2009-08-27 14:26                                           ` Thiago Farina
2009-09-07 12:26                                       ` Erik Faye-Lund
2009-08-21 21:02                   ` [PATCH 09/14] Avoid including windows.h in winansi.c " Junio C Hamano
2009-08-21 21:16                     ` Reece Dunn
2009-08-22 11:40                       ` Marius Storm-Olsen
2009-08-28  8:15                 ` [PATCH 08/14] Test for WIN32 instead of __MINGW32_ Paolo Bonzini
2009-08-21 17:37               ` [msysGit] [PATCH 07/14] Fix __stdcall/WINAPI placement and function prototype Johannes Sixt
2009-08-21 19:42                 ` Marius Storm-Olsen
2009-08-21 14:37           ` [PATCH 05/14] Change regerror() declaration from K&R style to ANSI C (C89) Frank Li
2009-08-21 20:10           ` [PATCH v2 05/14] Change regerror() definition " Marius Storm-Olsen
2009-08-22  0:15             ` Frank Li
2009-08-24  9:42             ` Erik Faye-Lund
2009-08-21 20:55       ` [PATCH 03/14] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ Junio C Hamano
2009-08-21 21:18         ` Johan 't Hart
2009-08-21 21:41         ` Johannes Sixt
2009-08-21 22:11           ` Junio C Hamano
2009-08-22 11:25             ` Marius Storm-Olsen
2009-08-22 11:32             ` Marius Storm-Olsen
2009-08-21 13:41   ` [PATCH 01/14] Fix non-constant array creation Erik Faye-Lund
2009-08-21 13:46     ` Marius Storm-Olsen
2009-08-21 16:26       ` [msysGit] " Janos Laube
2009-08-21 19:49         ` Marius Storm-Olsen
2009-08-21 20:06         ` Johan 't Hart
2009-08-22 10:35           ` Erik Faye-Lund
2009-08-21 21:04     ` Junio C Hamano
2009-08-21 20:39   ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af66de324093bbe8f500b1ef20689dd5d355abf4.1250860247.git.mstormo@gmail.com \
    --to=mstormo@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=lznuaa@gmail.com \
    --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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).