Skip to content

Commit 657b35f

Browse files
Ramsay Jonesgitster
authored andcommitted
compat/mingw.c: Fix some sparse warnings
Sparse issues the following warnings: SP compat/mingw.c compat/mingw.c:795:3: warning: symbol 'pinfo_t' was not declared. \ Should it be static? compat/mingw.c:796:16: warning: symbol 'pinfo' was not declared. \ Should it be static? compat/mingw.c:797:18: warning: symbol 'pinfo_cs' was not declared. \ Should it be static? compat/mingw.c:1207:23: warning: Using plain integer as NULL pointer In 'pinfo_t' variable, defined on line 795, seems to have been a mistake (a missing typedef keyword?), so we simply remove it. The 'pinfo' variable does not require more than file scope, so we simply add the static modifier to the declaration. The 'pinfo_cs' variable, in contrast, requires initialisation in the mingw replacement main() function, so we add an extern declaration to the compat/mingw.h header file. The remaining warning is suppressed by replacing the rhs of the pointer assignment with the NULL pointer literal. Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 15b7f60 commit 657b35f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compat/mingw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,8 @@ struct pinfo_t {
841841
struct pinfo_t *next;
842842
pid_t pid;
843843
HANDLE proc;
844-
} pinfo_t;
845-
struct pinfo_t *pinfo = NULL;
844+
};
845+
static struct pinfo_t *pinfo = NULL;
846846
CRITICAL_SECTION pinfo_cs;
847847

848848
static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,
@@ -1253,7 +1253,7 @@ static int WSAAPI getaddrinfo_stub(const char *node, const char *service,
12531253
else
12541254
sin->sin_addr.s_addr = INADDR_LOOPBACK;
12551255
ai->ai_addr = (struct sockaddr *)sin;
1256-
ai->ai_next = 0;
1256+
ai->ai_next = NULL;
12571257
return 0;
12581258
}
12591259

compat/mingw.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ void mingw_open_html(const char *path);
333333
char **make_augmented_environ(const char *const *vars);
334334
void free_environ(char **env);
335335

336+
/*
337+
* A critical section used in the implementation of the spawn
338+
* functions (mingw_spawnv[p]e()) and waitpid(). Intialised in
339+
* the replacement main() macro below.
340+
*/
341+
extern CRITICAL_SECTION pinfo_cs;
342+
336343
/*
337344
* A replacement of main() that ensures that argv[0] has a path
338345
* and that default fmode and std(in|out|err) are in binary mode

0 commit comments

Comments
 (0)