git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/6] compat/mingw.c: Fix some sparse warnings

From
Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Date
Apr 27, 2013, 19:18 UTC
Message-ID
<517C249F.6020909@ramsay1.demon.co.uk>
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 <ramsay@ramsay1.demon.co.uk>
---
 compat/mingw.c | 6 +++---
 compat/mingw.h | 7 +++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index b673625..b295e2f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -841,8 +841,8 @@ struct pinfo_t {
 	struct pinfo_t *next;
 	pid_t pid;
 	HANDLE proc;
-} pinfo_t;
-struct pinfo_t *pinfo = NULL;
+};
+static struct pinfo_t *pinfo = NULL;
 CRITICAL_SECTION pinfo_cs;
 
 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,
 	else
 		sin->sin_addr.s_addr = INADDR_LOOPBACK;
 	ai->ai_addr = (struct sockaddr *)sin;
-	ai->ai_next = 0;
+	ai->ai_next = NULL;
 	return 0;
 }
 
diff --git a/compat/mingw.h b/compat/mingw.h
index 685cd2c..3036980 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -334,6 +334,13 @@ char **make_augmented_environ(const char *const *vars);
 void free_environ(char **env);
 
 /*
+ * A critical section used in the implementation of the spawn
+ * functions (mingw_spawnv[p]e()) and waitpid(). Intialised in
+ * the replacement main() macro below.
+ */
+extern CRITICAL_SECTION pinfo_cs;
+
+/*
  * A replacement of main() that ensures that argv[0] has a path
  * and that default fmode and std(in|out|err) are in binary mode
  */
-- 
1.8.2
Message 1 of 1 in “compat/mingw.c: Fix some sparse warnings”
  1. 5/6 compat/mingw.c: Fix some sparse warningsRamsay Jones, Apr 27, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.