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}\"),
sql_help_$id,
$entries{$_}{nl_coun