{"thread":{"id":"33649","subject":"[PATCH 5/6] compat/mingw.c: Fix some sparse warnings","startedAt":"2013-04-27T19:18:55Z","lastAt":"2013-04-27T19:18:55Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"215733","messageId":"517C249F.6020909@ramsay1.demon.co.uk","threadId":"33649","inReplyTo":null,"subject":"[PATCH 5/6] compat/mingw.c: Fix some sparse warnings","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-04-27T19:18:55Z","receivedAt":"2013-04-27T19:18:55Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSparse issues the following warnings:\n\n        SP compat/mingw.c\n    compat/mingw.c:795:3: warning: symbol 'pinfo_t' was not declared. \\\n        Should it be static?\n    compat/mingw.c:796:16: warning: symbol 'pinfo' was not declared. \\\n        Should it be static?\n    compat/mingw.c:797:18: warning: symbol 'pinfo_cs' was not declared. \\\n        Should it be static?\n    compat/mingw.c:1207:23: warning: Using plain integer as NULL pointer\n\nIn 'pinfo_t' variable, defined on line 795, seems to have been a\nmistake (a missing typedef keyword?), so we simply remove it.\n\nThe 'pinfo' variable does not require more than file scope, so we\nsimply add the static modifier to the declaration.\n\nThe 'pinfo_cs' variable, in contrast, requires initialisation in the\nmingw replacement main() function, so we add an extern declaration to\nthe compat/mingw.h header file.\n\nThe remaining warning is suppressed by replacing the rhs of the\npointer assignment with the NULL pointer literal.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n compat/mingw.c | 6 +++---\n compat/mingw.h | 7 +++++++\n 2 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex b673625..b295e2f 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -841,8 +841,8 @@ struct pinfo_t {\n \tstruct pinfo_t *next;\n \tpid_t pid;\n \tHANDLE proc;\n-} pinfo_t;\n-struct pinfo_t *pinfo = NULL;\n+};\n+static struct pinfo_t *pinfo = NULL;\n CRITICAL_SECTION pinfo_cs;\n \n static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **env,\n@@ -1253,7 +1253,7 @@ static int WSAAPI getaddrinfo_stub(const char *node, const char *service,\n \telse\n \t\tsin->sin_addr.s_addr = INADDR_LOOPBACK;\n \tai->ai_addr = (struct sockaddr *)sin;\n-\tai->ai_next = 0;\n+\tai->ai_next = NULL;\n \treturn 0;\n }\n \ndiff --git a/compat/mingw.h b/compat/mingw.h\nindex 685cd2c..3036980 100644\n--- a/compat/mingw.h\n+++ b/compat/mingw.h\n@@ -334,6 +334,13 @@ char **make_augmented_environ(const char *const *vars);\n void free_environ(char **env);\n \n /*\n+ * A critical section used in the implementation of the spawn\n+ * functions (mingw_spawnv[p]e()) and waitpid(). Intialised in\n+ * the replacement main() macro below.\n+ */\n+extern CRITICAL_SECTION pinfo_cs;\n+\n+/*\n  * A replacement of main() that ensures that argv[0] has a path\n  * and that default fmode and std(in|out|err) are in binary mode\n  */\n-- \n1.8.2\n"}]}