Web lists-archives.com

Re: Q_ASSERT(!FalseSecurity)




On Saturday, 10 March 2018 00:53:24 PDT Michael Heidelbach wrote:
> Hi!
> 
> Am I getting something wrong? Or is
> 
>     "Q_ASSERT(m_writeTrans);
> 
>     m_writeTrans->commit();"
> 
> providing false security?

This is not false security. It's not security, period.

You use a Q_ASSERT when a violation indicates a bug that needs to be fixed, 
instead of a normal condition. So the above code is fine.

> Shouldn't it better be
> 
>     "Q_ASSERT(m_writeTrans);
> 
>     if (m_writeTrans) {
> 
>          m_writeTrans->commit(); ?

It should definitely NOT be this.

Use either Q_ASSERT or the if, not both.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center