Fix minor bugs in commit 30bf4689a9 et al.

Coverity complained that the "else" added to fillPGconn() was unreachable,
which it was.  Remove the dead code.  In passing, rearrange the tests so as
not to bother trying to fetch values for options that can't be assigned.

Pre-9.3 did not have that issue, but it did have a "return" that should be
"goto oom_error" to ensure that a suitable error message gets filled in.
This commit is contained in:
Tom Lane 2014-11-30 12:20:44 -05:00
parent 22dfd116a1
commit 1adbb347ec

View File

@ -684,16 +684,16 @@ fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
for (option = PQconninfoOptions; option->keyword; option++)
{
const char *tmp = conninfo_getval(connOptions, option->keyword);
if (tmp && option->connofs >= 0)
if (option->connofs >= 0)
{
char **connmember = (char **) ((char *) conn + option->connofs);
const char *tmp = conninfo_getval(connOptions, option->keyword);
if (*connmember)
free(*connmember);
if (tmp)
{
char **connmember = (char **) ((char *) conn + option->connofs);
if (*connmember)
free(*connmember);
*connmember = strdup(tmp);
if (*connmember == NULL)
{
@ -702,8 +702,6 @@ fillPGconn(PGconn *conn, PQconninfoOption *connOptions)
return false;
}
}
else
*connmember = NULL;
}
}
@ -793,7 +791,6 @@ connectOptions2(PGconn *conn)
conn->pgpass = strdup(DefaultPassword);
if (!conn->pgpass)
goto oom_error;
}
else
conn->dot_pgpass_used = true;