postgresql-10.0/src/bin/psql/mainloop.c:465: suspicious condition ?

Started by David Bindermanover 8 years ago4 messagesbugs
Jump to latest
#1David Binderman
dcb314@hotmail.com

Hello there,

postgresql-10.0/src/bin/psql/mainloop.c:461] -> [postgresql-10.0/src/bin/psql/mainloop.c:465]: (warning) Opposite inner 'if' condition leads to a dead code block.

Source code is

if (query_buf->len > 0 && !pset.cur_cmd_interactive &&
successResult == EXIT_SUCCESS)
{
/* save query in history */
if (pset.cur_cmd_interactive)
pg_send_history(history_buf);

It looks like function pg_send_history can never be executed.

Regards

David Binderman

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Binderman (#1)
Re: postgresql-10.0/src/bin/psql/mainloop.c:465: suspicious condition ?

David Binderman <dcb314@hotmail.com> writes:

postgresql-10.0/src/bin/psql/mainloop.c:461] -> [postgresql-10.0/src/bin/psql/mainloop.c:465]: (warning) Opposite inner 'if' condition leads to a dead code block.

Huh ... that code's been like that since 2006. Odd that nothing's
noticed the dead-ness before. What tool were you using?

regards, tom lane

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

#3David Binderman
dcb314@hotmail.com
In reply to: Tom Lane (#2)
Re: postgresql-10.0/src/bin/psql/mainloop.c:465: suspicious condition ?

Hello there,

Huh ... that code's been like that since 2006.  Odd that nothing's
noticed the dead-ness before.  What tool were you using?

cppcheck, available from sourceforge.

Regards

David Binderman

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

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Binderman (#3)
Re: postgresql-10.0/src/bin/psql/mainloop.c:465: suspicious condition ?

David Binderman <dcb314@hotmail.com> writes:

Huh ... that code's been like that since 2006.  Odd that nothing's
noticed the dead-ness before.  What tool were you using?

cppcheck, available from sourceforge.

Thanks. I've corrected this in HEAD, but it seems not worth
back-patching since it's really just cosmetic.

regards, tom lane

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