Small const correctness patch

Started by Mark Gover 6 years ago8 messageshackers
Jump to latest
#1Mark G
markg735@gmail.com

Hello all,

Please find attached a trivial patch making a few arrays const (in addition
to the data they point to).

Attachments:

constify-arrays.patchtext/x-patch; charset=US-ASCII; name=constify-arrays.patchDownload+3-3
#2Ibrar Ahmed
ibrar.ahmad@gmail.com
In reply to: Mark G (#1)
Re: Small const correctness patch

+1

Patch successfully applied to the master (
43211c2a02f39d6568496168413dc00e0399dc2e)

On Thu, Aug 8, 2019 at 12:30 PM Mark G <markg735@gmail.com> wrote:

Hello all,

Please find attached a trivial patch making a few arrays const (in
addition to the data they point to).

--
Ibrar Ahmed

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Mark G (#1)
Re: Small const correctness patch

On 2019-08-08 08:46, Mark G wrote:

Please find attached a trivial patch making a few arrays const (in
addition to the data they point to).

How did you find this? Any special compiler settings?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#4Mark G
markg735@gmail.com
In reply to: Peter Eisentraut (#3)
Re: Small const correctness patch

On Thu, Aug 8, 2019 at 8:51 PM Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:

How did you find this? Any special compiler settings?

16 hours stuck in a plane on an international flight. I was just eyeballing
the code to kill the boredom.

-Mark

#5Mark G
markg735@gmail.com
In reply to: Ibrar Ahmed (#2)
Re: Small const correctness patch

On Thu, Aug 8, 2019 at 8:25 PM Ibrar Ahmed <ibrar.ahmad@gmail.com> wrote:

+1

Patch successfully applied to the master (
43211c2a02f39d6568496168413dc00e0399dc2e)

That change looks like an unrelated patch for initdb. I'm still not seeing
my patch there.

-Mark

#6Ibrar Ahmed
ibrar.ahmad@gmail.com
In reply to: Mark G (#5)
Re: Small const correctness patch

On Fri, Aug 9, 2019 at 1:25 AM Mark G <markg735@gmail.com> wrote:

On Thu, Aug 8, 2019 at 8:25 PM Ibrar Ahmed <ibrar.ahmad@gmail.com> wrote:

+1

Patch successfully applied to the master (
43211c2a02f39d6568496168413dc00e0399dc2e)

That change looks like an unrelated patch for initdb. I'm still not seeing
my patch there.

I said I checked and verified patch against that hash. It applied to that
without any failure. Sorry for the confusion.

-Mark

--
Ibrar Ahmed

#7Kyotaro Horiguchi
horikyota.ntt@gmail.com
In reply to: Mark G (#4)
Re: Small const correctness patch

At Thu, 8 Aug 2019 22:56:02 +0300, Mark G <markg735@gmail.com> wrote in <CAEeOP_Y3SAXe8u++9e-CN_+MgY9_u+vu3a80sw+7gzR4s7KjqQ@mail.gmail.com>

On Thu, Aug 8, 2019 at 8:51 PM Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:

How did you find this? Any special compiler settings?

16 hours stuck in a plane on an international flight. I was just eyeballing
the code to kill the boredom.

A similar loose typing is seen, for example:p

-const char *
+const char * const

src/backend/access/rmgrdesc/*.c
relmap_identify(uint8 info)
seq_identify(uint8 info)
smgr_identify(uint8 info)
.... (many)...

src/backend/access/transam/xact.c:
BlockStateAsString(TBlockState blockState)

I foundnd them by

find $(TOP) -type f -exec egrep -nH -e '^(static )?const char \*' {} +

then eyeballing on the first ones. I don't know an automated way
to detect such possibly-loose constness of variables or
functions.

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

#8Peter Eisentraut
peter_e@gmx.net
In reply to: Mark G (#1)
Re: Small const correctness patch

On 2019-08-08 08:46, Mark G wrote:

Please find attached a trivial patch making a few arrays const (in
addition to the data they point to).

committed

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services