[PATCH] Removes uninitialized variable compiler warning

Started by Todd Sedanoabout 9 years ago3 messageshackers
Jump to latest
#1Todd Sedano
tsedano@pivotal.io

This patch removes a compiler warning.

warning: variable 'lenlemm' is uninitialized when used here
[-Wuninitialized]

This is my first commit to postgres. I've read through
http://wiki.postgresql.org/wiki/Submitting_a_Patch, but I may have missed
something.

diff --git a/src/backend/tsearch/ts_parse.c b/src/backend/tsearch/ts_parse.c
index b612fb0e2c..3d66b2babd 100644
--- a/src/backend/tsearch/ts_parse.c
+++ b/src/backend/tsearch/ts_parse.c
@@ -357,8 +357,8 @@ LexizeExec(LexizeData *ld, ParsedLex **correspondLexem)
 void
 parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
 {
-       int                     type,
-                               lenlemm;
+       int                     type;
+       int                     lenlemm = 0;
        char       *lemm = NULL;
        LexizeData      ldata;
        TSLexeme   *norms;

Attachments:

lenlemm_remove_compiler_warning.patchapplication/octet-stream; name=lenlemm_remove_compiler_warning.patchDownload+2-2
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Todd Sedano (#1)
Re: [PATCH] Removes uninitialized variable compiler warning

Todd Sedano <tsedano@pivotal.io> writes:

This patch removes a compiler warning.
warning: variable 'lenlemm' is uninitialized when used here
[-Wuninitialized]

Hm, on what compiler? AFAICS, that parsetext() function hasn't
changed meaningfully since 2007, and nobody complained of
uninitialized-variable warnings in it before.

We're generally willing to try to silence such warnings on mainstream
compilers, but not on weird ones ...

regards, tom lane

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

#3Todd Sedano
tsedano@pivotal.io
In reply to: Tom Lane (#2)
Re: [PATCH] Removes uninitialized variable compiler warning

We can disregard this patch. It appears that PointerGetDatum initializes
lenlemm.

On Mon, Mar 20, 2017 at 10:04 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Todd Sedano <tsedano@pivotal.io> writes:

This patch removes a compiler warning.
warning: variable 'lenlemm' is uninitialized when used here
[-Wuninitialized]

Hm, on what compiler? AFAICS, that parsetext() function hasn't
changed meaningfully since 2007, and nobody complained of
uninitialized-variable warnings in it before.

We're generally willing to try to silence such warnings on mainstream
compilers, but not on weird ones ...

regards, tom lane