Re: [HACKERS] GCC 6 warning fixes

2016-03-08 Thread Peter Eisentraut
On 3/8/16 4:44 PM, Robert Haas wrote:
> On Mon, Feb 29, 2016 at 4:50 PM, Thomas Munro
>  wrote:
>> On Sat, Feb 20, 2016 at 5:14 PM, Peter Eisentraut  wrote:
>>> Here are three patches to fix new warnings in GCC 6.
>>>
>>> 0001 is apparently a typo.
>>
>> Right, looks like it.  Builds and tests OK with this change (though I
>> didn't get any warning from GCC6.0.0 -Wall for this one).
>>
>>> 0002 was just (my?) stupid code to begin with.
>>
>> Right, it makes sense to define QL_HELP in just one translation unit
>> with external linkage.  Builds and works fine.  I got the 'defined but
>> not used' warning from GCC6 and it went away with this patch.
>>
>>> 0003 is more of a workaround.  There could be other ways address this, too.
>>
>> This way seems fine to me (you probably want the function to continue
>> to exist rather than, say, becoming a macro evaluating to false on
>> non-WIN32, if this gets backpatched).  I got this warning from GCC6
>> and it went away with this patch.
> 
> Peter, are you going to commit this?

done



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] GCC 6 warning fixes

2016-03-08 Thread Robert Haas
On Mon, Feb 29, 2016 at 4:50 PM, Thomas Munro
 wrote:
> On Sat, Feb 20, 2016 at 5:14 PM, Peter Eisentraut  wrote:
>> Here are three patches to fix new warnings in GCC 6.
>>
>> 0001 is apparently a typo.
>
> Right, looks like it.  Builds and tests OK with this change (though I
> didn't get any warning from GCC6.0.0 -Wall for this one).
>
>> 0002 was just (my?) stupid code to begin with.
>
> Right, it makes sense to define QL_HELP in just one translation unit
> with external linkage.  Builds and works fine.  I got the 'defined but
> not used' warning from GCC6 and it went away with this patch.
>
>> 0003 is more of a workaround.  There could be other ways address this, too.
>
> This way seems fine to me (you probably want the function to continue
> to exist rather than, say, becoming a macro evaluating to false on
> non-WIN32, if this gets backpatched).  I got this warning from GCC6
> and it went away with this patch.

Peter, are you going to commit this?

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] GCC 6 warning fixes

2016-02-29 Thread Thomas Munro
On Sat, Feb 20, 2016 at 5:14 PM, Peter Eisentraut  wrote:
> Here are three patches to fix new warnings in GCC 6.
>
> 0001 is apparently a typo.

Right, looks like it.  Builds and tests OK with this change (though I
didn't get any warning from GCC6.0.0 -Wall for this one).

> 0002 was just (my?) stupid code to begin with.

Right, it makes sense to define QL_HELP in just one translation unit
with external linkage.  Builds and works fine.  I got the 'defined but
not used' warning from GCC6 and it went away with this patch.

> 0003 is more of a workaround.  There could be other ways address this, too.

This way seems fine to me (you probably want the function to continue
to exist rather than, say, becoming a macro evaluating to false on
non-WIN32, if this gets backpatched).  I got this warning from GCC6
and it went away with this patch.

-- 
Thomas Munro
http://www.enterprisedb.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] GCC 6 warning fixes

2016-02-19 Thread Peter Eisentraut
Here are three patches to fix new warnings in GCC 6.

0001 is apparently a typo.

0002 was just (my?) stupid code to begin with.

0003 is more of a workaround.  There could be other ways address this, too.
From 1e5bf0bdcd86b807d881ea82245275389083ec75 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut 
Date: Fri, 19 Feb 2016 23:07:46 -0500
Subject: [PATCH 1/3] ecpg: Fix typo

GCC 6 points out the redundant conditions, which were apparently typos.
---
 src/interfaces/ecpg/test/compat_informix/describe.pgc| 2 +-
 src/interfaces/ecpg/test/expected/compat_informix-describe.c | 2 +-
 src/interfaces/ecpg/test/expected/sql-describe.c | 2 +-
 src/interfaces/ecpg/test/sql/describe.pgc| 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/interfaces/ecpg/test/compat_informix/describe.pgc b/src/interfaces/ecpg/test/compat_informix/describe.pgc
index 1836ac3..6f6 100644
--- a/src/interfaces/ecpg/test/compat_informix/describe.pgc
+++ b/src/interfaces/ecpg/test/compat_informix/describe.pgc
@@ -150,7 +150,7 @@ exec sql end declare section;
 	exec sql describe st_id2 using descriptor sqlda2;
 	exec sql describe st_id2 into sqlda3;
 
-	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+	if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
 		exit(1);
 
 	strcpy(msg, "get descriptor");
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-describe.c b/src/interfaces/ecpg/test/expected/compat_informix-describe.c
index 5951ae6..9eb176e 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-describe.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-describe.c
@@ -362,7 +362,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 151 "describe.pgc"
 
 
-	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+	if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
 		exit(1);
 
 	strcpy(msg, "get descriptor");
diff --git a/src/interfaces/ecpg/test/expected/sql-describe.c b/src/interfaces/ecpg/test/expected/sql-describe.c
index 356f587..d0e39e9 100644
--- a/src/interfaces/ecpg/test/expected/sql-describe.c
+++ b/src/interfaces/ecpg/test/expected/sql-describe.c
@@ -360,7 +360,7 @@ if (sqlca.sqlcode < 0) exit (1);}
 #line 151 "describe.pgc"
 
 
-	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+	if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
 		exit(1);
 
 	strcpy(msg, "get descriptor");
diff --git a/src/interfaces/ecpg/test/sql/describe.pgc b/src/interfaces/ecpg/test/sql/describe.pgc
index cd52c82..b95ab35 100644
--- a/src/interfaces/ecpg/test/sql/describe.pgc
+++ b/src/interfaces/ecpg/test/sql/describe.pgc
@@ -150,7 +150,7 @@ exec sql end declare section;
 	exec sql describe st_id2 using descriptor sqlda2;
 	exec sql describe st_id2 into sqlda3;
 
-	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+	if (sqlda1 == NULL || sqlda2 == NULL || sqlda3 == NULL)
 		exit(1);
 
 	strcpy(msg, "get descriptor");
-- 
2.7.1

From 996a5d27a2bc79e1e0b2ee0aa39cfdc7615e874c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut 
Date: Fri, 19 Feb 2016 23:07:46 -0500
Subject: [PATCH 2/3] psql: Fix some strange code in SQL help creation

Struct QL_HELP used to be defined as static in the sql_help.h header
file, which is included in sql_help.c and help.c, thus creating two
separate instances of the struct.  This causes a warning from GCC 6,
because the struct is not used in sql_help.c.

Instead, declare the struct as extern in the header file and define it
in sql_help.c.  This also allows making a bunch of functions static
because they are no longer needed outside of sql_help.c.
---
 src/bin/psql/create_help.pl | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl
index fedcc47..b9b8e87 100644
--- a/src/bin/psql/create_help.pl
+++ b/src/bin/psql/create_help.pl
@@ -59,8 +59,6 @@
 #ifndef $define
 #define $define
 
-#define N_(x) (x)/* gettext noop */
-
 #include \"postgres_fe.h\"
 #include \"pqexpbuffer.h\"
 
@@ -72,6 +70,7 @@
 	intnl_count;	/* number of newlines in syntax (for pager) */
 };
 
+extern const struct _helpStruct QL_HELP[];
 ";
 
 print CFILE "/*
@@ -83,6 +82,8 @@
  *
  */
 
+#define N_(x) (x)/* gettext noop */
+
 #include \"$hfile\"
 
 ";
@@ -170,8 +171,7 @@
 	$synopsis =~ s/\\n/\\n"\n$prefix"/g;
 	my @args =
 	  ("buf", $synopsis, map("_(\"$_\")", @{ $entries{$_}{params} }));
-	print HFILE "extern void sql_help_$id(PQExpBuffer buf);\n";
-	print CFILE "void
+	print CFILE "static void
 sql_help_$id(PQExpBuffer buf)
 {
 \tappendPQExpBuffer(" . join(",\n$prefix", @args) . ");
@@ -180,15 +180,14 @@
 ";
 }
 
-print HFILE "
-
-static const struct _helpStruct QL_HELP[] = {
+print CFILE "
+const struct _helpStruct QL_HELP[] = {
 ";
 foreach (sort keys %entries)
 {
 	my $id = $_;
 	$id =~ s/ /_/g;
-	print HFILE "{ \"$_\",
+	print CFILE "{ \"$_\",
   N_(\"$entries{$_}{cmddesc}\"),