From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Andres Freund <andres(at)anarazel(dot)de> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se> |
Subject: | compiler warnings with gcc 4.8 and -Og |
Date: | 2022-06-02 02:42:44 |
Message-ID: | 20220602024243.GJ29853@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
forking: <20220302205058(dot)GJ15744(at)telsasoft(dot)com>: Re: Adding CI to our tree
On Wed, Mar 02, 2022 at 02:50:58PM -0600, Justin Pryzby wrote:
> BTW (regarding the last patch), I just noticed that -Og optimization can cause
> warnings with gcc-4.8.5-39.el7.x86_64.
>
> be-fsstubs.c: In function 'be_lo_export':
> be-fsstubs.c:522:24: warning: 'fd' may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (CloseTransientFile(fd) != 0)
> ^
> trigger.c: In function 'ExecCallTriggerFunc':
> trigger.c:2400:2: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized]
> return (HeapTuple) DatumGetPointer(result);
> ^
> xml.c: In function 'xml_pstrdup_and_free':
> xml.c:1205:2: warning: 'result' may be used uninitialized in this function [-Wmaybe-uninitialized]
> return result;
Today's "warnings" thread suggests to me that these are worth fixing - it seems
reasonable to compile postgres 14 on centos7 (as I sometimes have done), and
the patch seems even more reasonable when backpatched to older versions.
(Also, I wonder if there's any consideration to backpatch cirrus.yaml, which
uses -Og)
The buildfarm has old GCC, but they all use -O2, so the warnings are not seen
there.
The patch below applies and fixes warnings back to v13.
In v13, pl_handler.c has another warning, which suggests to backpatch
7292fd8f1.
In v12, there's a disparate separate set of warnings which could be dealt with
separately.
v9.3-v11 have no warnings on c7 with -Og.
Thomas mentioned [0] that cfbot's linux (which is using gcc 10) gives other
warnings since using -Og, which (in addition to being unpleasant to look at) is
hard to accept, seeing as there's a whole separate task just for
"CompilerWarnings"... But I don't know what to do about those.
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 40441fdb4c..bb64de2843 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -2105,7 +2105,7 @@ ExecCallTriggerFunc(TriggerData *trigdata,
{
LOCAL_FCINFO(fcinfo, 0);
PgStat_FunctionCallUsage fcusage;
- Datum result;
+ Datum result = 0;
MemoryContext oldContext;
/*
diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c
index 63eaccc80a..3e2c094e1e 100644
--- a/src/backend/libpq/be-fsstubs.c
+++ b/src/backend/libpq/be-fsstubs.c
@@ -467,7 +467,7 @@ be_lo_export(PG_FUNCTION_ARGS)
{
Oid lobjId = PG_GETARG_OID(0);
text *filename = PG_GETARG_TEXT_PP(1);
- int fd;
+ int fd = -1;
int nbytes,
tmp;
char buf[BUFSIZE];
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index f90a9424d4..7ffbae5a09 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -1185,7 +1185,7 @@ pg_xmlCharStrndup(const char *str, size_t len)
static char *
xml_pstrdup_and_free(xmlChar *str)
{
- char *result;
+ char *result = NULL;
if (str)
{
@@ -1199,8 +1199,6 @@ xml_pstrdup_and_free(xmlChar *str)
}
PG_END_TRY();
}
- else
- result = NULL;
return result;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2022-06-02 04:24:28 | Re: compiler warnings with gcc 4.8 and -Og |
Previous Message | Michael Paquier | 2022-06-02 01:37:51 | Re: [PATCH] Fix pg_upgrade test from v10 |