Compiler warnings fix

Started by ITAGAKI Takahiroalmost 17 years ago6 messages
#1ITAGAKI Takahiro
itagaki.takahiro@oss.ntt.co.jp
1 attachment(s)

Here is a patch to surpress compiler warnings in pg_locale.c and pg_regress.c.

There are following warnings if nls is enabled:
pg_locale.c: In function `pg_perm_setlocale':
pg_locale.c:161: warning: assignment discards qualifiers from pointer target type
and if nls is disabled:
pg_locale.c:615: warning: 'IsoLocaleName' defined but not used

There is also a warning in pg_regress.c:
pg_regress.c: In function `wait_for_tests':
pg_regress.c:1367: warning: passing arg 2 of `GetExitCodeProcess' from incompatible pointer type

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Attachments:

fix_warnings.patchapplication/octet-stream; name=fix_warnings.patchDownload
Index: src/backend/utils/adt/pg_locale.c
===================================================================
--- src/backend/utils/adt/pg_locale.c	(HEAD)
+++ src/backend/utils/adt/pg_locale.c	(working copy)
@@ -92,7 +92,7 @@
 static char lc_numeric_envbuf[LC_ENV_BUFSIZE];
 static char lc_time_envbuf[LC_ENV_BUFSIZE];
 
-#ifdef WIN32
+#if defined(WIN32) && defined(LC_MESSAGES)
 static char *IsoLocaleName(const char *); /* MSVC specific */
 #endif
 
@@ -158,7 +158,7 @@
 #ifdef WIN32
 			result = IsoLocaleName(locale);
 			if (result == NULL)
-				result = locale;
+				result = (char *) locale;
 #endif /* WIN32 */
 			break;
 #endif /* LC_MESSAGES */
@@ -601,7 +601,7 @@
 }
 
 
-#ifdef WIN32
+#if defined(WIN32) && defined(LC_MESSAGES)
 /*
  *	Convert Windows locale name to the ISO formatted one
  *	if possible.
@@ -647,5 +647,5 @@
 	return NULL; /* Not supported on this version of msvc/mingw */
 #endif /* _MSC_VER >= 1400 */
 }
-#endif /* WIN32 */
+#endif /* WIN32 && LC_MESSAGES */
 
Index: src/test/regress/pg_regress.c
===================================================================
--- src/test/regress/pg_regress.c	(HEAD)
+++ src/test/regress/pg_regress.c	(working copy)
@@ -1364,7 +1364,7 @@
 			if (p == pids[i])
 			{
 #ifdef WIN32
-				GetExitCodeProcess(pids[i], &exit_status);
+				GetExitCodeProcess(pids[i], (LPDWORD) &exit_status);
 				CloseHandle(pids[i]);
 #endif
 				pids[i] = INVALID_PID;
#2Peter Eisentraut
peter_e@gmx.net
In reply to: ITAGAKI Takahiro (#1)
Re: Compiler warnings fix

ITAGAKI Takahiro wrote:

Here is a patch to surpress compiler warnings in pg_locale.c and pg_regress.c.

There are following warnings if nls is enabled:
pg_locale.c: In function `pg_perm_setlocale':
pg_locale.c:161: warning: assignment discards qualifiers from pointer target type
and if nls is disabled:
pg_locale.c:615: warning: 'IsoLocaleName' defined but not used

There is also a warning in pg_regress.c:
pg_regress.c: In function `wait_for_tests':
pg_regress.c:1367: warning: passing arg 2 of `GetExitCodeProcess' from incompatible pointer type

Which platform, which compiler, what configure options?

#3ITAGAKI Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Peter Eisentraut (#2)
Re: Compiler warnings fix

Peter Eisentraut <peter_e@gmx.net> wrote:

ITAGAKI Takahiro wrote:

Here is a patch to surpress compiler warnings in pg_locale.c and pg_regress.c.

There are following warnings if nls is enabled:
pg_locale.c: In function `pg_perm_setlocale':
pg_locale.c:161: warning: assignment discards qualifiers from pointer target type
and if nls is disabled:
pg_locale.c:615: warning: 'IsoLocaleName' defined but not used

There is also a warning in pg_regress.c:
pg_regress.c: In function `wait_for_tests':
pg_regress.c:1367: warning: passing arg 2 of `GetExitCodeProcess' from incompatible pointer type

Which platform, which compiler, what configure options?

It is in mingw, gcc.exe (GCC) 3.4.5 (mingw-vista special r3).

There are same warning on vaquita in buildfarm.
http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=vaquita&amp;dt=2009-01-26%20210011&amp;stg=make

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#4Andrew Dunstan
andrew@dunslane.net
In reply to: ITAGAKI Takahiro (#3)
Re: Compiler warnings fix

ITAGAKI Takahiro wrote:

Peter Eisentraut <peter_e@gmx.net> wrote:

ITAGAKI Takahiro wrote:

Here is a patch to surpress compiler warnings in pg_locale.c and pg_regress.c.

There are following warnings if nls is enabled:
pg_locale.c: In function `pg_perm_setlocale':
pg_locale.c:161: warning: assignment discards qualifiers from pointer target type
and if nls is disabled:
pg_locale.c:615: warning: 'IsoLocaleName' defined but not used

There is also a warning in pg_regress.c:
pg_regress.c: In function `wait_for_tests':
pg_regress.c:1367: warning: passing arg 2 of `GetExitCodeProcess' from incompatible pointer type

Which platform, which compiler, what configure options?

It is in mingw, gcc.exe (GCC) 3.4.5 (mingw-vista special r3).

There are same warning on vaquita in buildfarm.
http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=vaquita&amp;dt=2009-01-26%20210011&amp;stg=make

Wouldn't we be better off using defined(ENABLE_NLS) instead of
defined(LC_MESSAGES) ?

cheers

andrew

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andrew Dunstan (#4)
Re: Compiler warnings fix

Andrew Dunstan <andrew@dunslane.net> writes:

There are same warning on vaquita in buildfarm.
http://www.pgbuildfarm.org/cgi-bin/show_stage_log.pl?nm=vaquita&amp;dt=2009-01-26%20210011&amp;stg=make

Wouldn't we be better off using defined(ENABLE_NLS) instead of
defined(LC_MESSAGES) ?

No, because the purpose of that #if is to prevent choking on the
references to LC_MESSAGES if it's not defined. Whether ENABLE_NLS
is defined is 100% orthogonal to that.

Given the current usage it seems that the only way to avoid the
"'IsoLocaleName' defined but not used" warning is to compile it
conditionally on LC_MESSAGES as well as WIN32. I agree that's
kind of ugly, but that's what the usage is.

regards, tom lane

#6Magnus Hagander
magnus@hagander.net
In reply to: ITAGAKI Takahiro (#1)
Re: Compiler warnings fix

ITAGAKI Takahiro wrote:

Here is a patch to surpress compiler warnings in pg_locale.c and pg_regress.c.

There are following warnings if nls is enabled:
pg_locale.c: In function `pg_perm_setlocale':
pg_locale.c:161: warning: assignment discards qualifiers from pointer target type
and if nls is disabled:
pg_locale.c:615: warning: 'IsoLocaleName' defined but not used

There is also a warning in pg_regress.c:
pg_regress.c: In function `wait_for_tests':
pg_regress.c:1367: warning: passing arg 2 of `GetExitCodeProcess' from incompatible pointer type

Applied (as two separate patches since I missed that there were two
files initially).

I agree with other comments that #ifdef:ing on LC_MESSAGES may not be
the greatest-looking solution, but the code that calls it is ifdef:ed
that way, so mimicking that seems like the right thing to do at this time.

//Magnus