@matheusbsbs / matheus-bagliano / commits / 0d30ad71fa
Fork 0

Avoid declaration after statement

MSVC does not understand this C99 style. Signed-off-by: Frank Li <lznuaa@gmail.com> Signed-off-by: Marius Storm-Olsen <mstormo@gmail.com> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Frank Li committed Sep 16, 2009 at 10:20 UTC 0d30ad71fa094dd89ae31b3381c2e63a41119c76
3 files changed +14 -5
compat/mingw.c
+10 -4
@@ -123,13 +123,17 @@ int mingw_open (const char *filename, int oflags, ...)
123 {
124 va_list args;
125 unsigned mode;
126 + int fd;
127 +
128 va_start(args, oflags);
129 mode = va_arg(args, int);
130 va_end(args);
131
132 if (!strcmp(filename, "/dev/null"))
133 filename = "nul";
132 - int fd = open(filename, oflags, mode);
134 +
135 + fd = open(filename, oflags, mode);
136 +
137 if (fd < 0 && (oflags & O_CREAT) && errno == EACCES) {
138 DWORD attrs = GetFileAttributes(filename);
139 if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY))
@@ -580,10 +584,11 @@ static char **get_path_split(void)
584
585 static void free_path_split(char **path)
586 {
587 + char **p = path;
588 +
589 if (!path)
590 return;
591
586 - char **p = path;
592 while (*p)
593 free(*p++);
594 free(path);
@@ -1120,9 +1125,9 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
1125 #undef signal
1126 sig_handler_t mingw_signal(int sig, sig_handler_t handler)
1127 {
1128 + sig_handler_t old = timer_fn;
1129 if (sig != SIGALRM)
1130 return signal(sig, handler);
1125 - sig_handler_t old = timer_fn;
1131 timer_fn = handler;
1132 return old;
1133 }
@@ -1209,8 +1214,9 @@ struct dirent *mingw_readdir(DIR *dir)
1214
1215 if (dir->dd_handle == (long)INVALID_HANDLE_VALUE && dir->dd_stat == 0)
1216 {
1217 + DWORD lasterr;
1218 handle = FindFirstFileA(dir->dd_name, &buf);
1213 - DWORD lasterr = GetLastError();
1219 + lasterr = GetLastError();
1220 dir->dd_handle = (long)handle;
1221 if (handle == INVALID_HANDLE_VALUE && (lasterr != ERROR_NO_MORE_FILES)) {
1222 errno = err_win_to_posix(lasterr);
help.c
+2 -1
@@ -127,7 +127,7 @@ static int is_executable(const char *name)
127 return 0;
128
129 #ifdef __MINGW32__
130 - /* cannot trust the executable bit, peek into the file instead */
130 +{ /* cannot trust the executable bit, peek into the file instead */
131 char buf[3] = { 0 };
132 int n;
133 int fd = open(name, O_RDONLY);
@@ -140,6 +140,7 @@ static int is_executable(const char *name)
140 st.st_mode |= S_IXUSR;
141 close(fd);
142 }
143 +}
144 #endif
145 return st.st_mode & S_IXUSR;
146 }
run-command.c
+2
@@ -134,6 +134,7 @@ fail_pipe:
134 error("cannot fork() for %s: %s", cmd->argv[0],
135 strerror(failed_errno = errno));
136 #else
137 +{
138 int s0 = -1, s1 = -1, s2 = -1; /* backups of stdin, stdout, stderr */
139 const char **sargv = cmd->argv;
140 char **env = environ;
@@ -197,6 +198,7 @@ fail_pipe:
198 dup2(s1, 1), close(s1);
199 if (s2 >= 0)
200 dup2(s2, 2), close(s2);
201 +}
202 #endif
203
204 if (cmd->pid < 0) {