Re: [HACKERS] psql commandline conninfo - Mailing list pgsql-patches

From Tom Lane
Subject Re: [HACKERS] psql commandline conninfo
Date
Msg-id 29216.1166283520@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] psql commandline conninfo  ("Andrew Dunstan" <andrew@dunslane.net>)
List pgsql-patches
"Andrew Dunstan" <andrew@dunslane.net> writes:
> BTW, what is the approved way to handle warnings about const? Copy the
> object?

Well, in the revised code there shouldn't be any warning at all, but
I think the mistake in your original was to declare the local variable
as "char *" instead of "const char *".

If "const" is being used as intended then a const-violation warning
would indeed suggest that you needed to make a writable copy.
Sometimes the problem is that you're working in a chunk of inadequately
const-ified code, ie, you're passing a const argument to some other
functions that do indeed treat their inputs as read-only but don't
declare them const.  In such cases you can either run around and try to
inject const everywhere it should be, or hold your nose and use a cast,
or give up on marking your own argument const :-(.  But you weren't
presented with that problem here, because connectOptions1() is already
const-ified.

            regards, tom lane

pgsql-patches by date:

Previous
From: "Andrew Dunstan"
Date:
Subject: Re: [HACKERS] psql commandline conninfo
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] psql commandline conninfo