Kaydet (Commit) 42bd4103 authored tarafından Chris Sherlock's avatar Chris Sherlock

rtl: cleanup cipher.cxx equality conditions

Change-Id: I0b8084adea65f8c6a6e5e46b6628297fbd9eda9b
üst 4f9cd941
......@@ -135,9 +135,10 @@ rtlCipherError SAL_CALL rtl_cipher_init(
const sal_uInt8 *pArgData, sal_Size nArgLen) SAL_THROW_EXTERN_C()
{
Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (pImpl->m_init == nullptr)
if (!pImpl->m_init)
return rtl_Cipher_E_Unknown;
return (pImpl->m_init)(
......@@ -150,9 +151,10 @@ rtlCipherError SAL_CALL rtl_cipher_encode(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (pImpl->m_encode == nullptr)
if (!pImpl->m_encode)
return rtl_Cipher_E_Unknown;
return (pImpl->m_encode)(Cipher, pData, nDatLen, pBuffer, nBufLen);
......@@ -164,9 +166,10 @@ rtlCipherError SAL_CALL rtl_cipher_decode(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
Cipher_Impl *pImpl = static_cast<Cipher_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (pImpl->m_decode == nullptr)
if (!pImpl->m_decode)
return rtl_Cipher_E_Unknown;
return (pImpl->m_decode)(Cipher, pData, nDatLen, pBuffer, nBufLen);
......@@ -681,10 +684,10 @@ static rtlCipherError BF_update(
sal_uInt8 *pBuffer, sal_Size nBufLen)
{
/* Check arguments. */
if ((pData == nullptr) || (pBuffer == nullptr))
if (!pData || !pBuffer)
return rtl_Cipher_E_Argument;
if (!((0 < nDatLen) && (nDatLen <= nBufLen)))
if (!((nDatLen > 0) && (nDatLen <= nBufLen)))
return rtl_Cipher_E_BufferSize;
/* Update. */
......@@ -939,7 +942,7 @@ rtlCipher SAL_CALL rtl_cipher_createBF(rtlCipherMode Mode) SAL_THROW_EXTERN_C()
CipherBF_Impl *pImpl = nullptr;
if (Mode == rtl_Cipher_ModeInvalid)
return (nullptr);
return nullptr;
pImpl = static_cast<CipherBF_Impl*>(rtl_allocateZeroMemory(sizeof (CipherBF_Impl)));
if (pImpl)
......@@ -964,13 +967,13 @@ rtlCipherError SAL_CALL rtl_cipher_initBF(
{
CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher);
if ((pImpl == nullptr) || (pKeyData == nullptr))
if (!pImpl || !pKeyData)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmBF)
return rtl_Cipher_E_Algorithm;
if (!(Direction == rtl_Cipher_DirectionInvalid))
if (Direction != rtl_Cipher_DirectionInvalid)
pImpl->m_cipher.m_direction = Direction;
else
return rtl_Cipher_E_Direction;
......@@ -986,14 +989,15 @@ rtlCipherError SAL_CALL rtl_cipher_encodeBF(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmBF)
return rtl_Cipher_E_Algorithm;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid)
return rtl_Cipher_E_Direction;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionDecode)
return rtl_Cipher_E_Direction;
......@@ -1009,14 +1013,15 @@ rtlCipherError SAL_CALL rtl_cipher_decodeBF(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
CipherBF_Impl *pImpl = static_cast<CipherBF_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmBF))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmBF)
return rtl_Cipher_E_Algorithm;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid)
return rtl_Cipher_E_Direction;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionEncode)
return rtl_Cipher_E_Direction;
......@@ -1115,7 +1120,7 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl(
sal_Size k;
/* Check arguments. */
if ((pData == nullptr) || (pBuffer == nullptr))
if (!pData || !pBuffer)
return rtl_Cipher_E_Argument;
if (!((0 < nDatLen) && (nDatLen <= nBufLen)))
......@@ -1156,8 +1161,8 @@ rtlCipher SAL_CALL rtl_cipher_createARCFOUR(rtlCipherMode Mode)
{
CipherARCFOUR_Impl *pImpl = nullptr;
if (!(Mode == rtl_Cipher_ModeStream))
return (nullptr);
if (Mode != rtl_Cipher_ModeStream)
return nullptr;
pImpl = static_cast<CipherARCFOUR_Impl*>(rtl_allocateZeroMemory(sizeof(CipherARCFOUR_Impl)));
if (pImpl)
......@@ -1184,18 +1189,18 @@ rtlCipherError SAL_CALL rtl_cipher_initARCFOUR(
{
CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher);
if ((pImpl == nullptr) || (pKeyData == nullptr))
if (!pImpl || !pKeyData)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmARCFOUR)
return rtl_Cipher_E_Algorithm;
if (!(Direction == rtl_Cipher_DirectionInvalid))
if (Direction != rtl_Cipher_DirectionInvalid)
pImpl->m_cipher.m_direction = Direction;
else
return rtl_Cipher_E_Direction;
return rtl_cipherARCFOUR_init_Impl (&(pImpl->m_context), pKeyData, nKeyLen);
return rtl_cipherARCFOUR_init_Impl(&(pImpl->m_context), pKeyData, nKeyLen);
}
rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR(
......@@ -1204,10 +1209,10 @@ rtlCipherError SAL_CALL rtl_cipher_encodeARCFOUR(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmARCFOUR)
return rtl_Cipher_E_Algorithm;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid)
......@@ -1224,10 +1229,10 @@ rtlCipherError SAL_CALL rtl_cipher_decodeARCFOUR(
sal_uInt8 *pBuffer, sal_Size nBufLen) SAL_THROW_EXTERN_C()
{
CipherARCFOUR_Impl *pImpl = static_cast<CipherARCFOUR_Impl*>(Cipher);
if (pImpl == nullptr)
if (!pImpl)
return rtl_Cipher_E_Argument;
if (!(pImpl->m_cipher.m_algorithm == rtl_Cipher_AlgorithmARCFOUR))
if (pImpl->m_cipher.m_algorithm != rtl_Cipher_AlgorithmARCFOUR)
return rtl_Cipher_E_Algorithm;
if (pImpl->m_cipher.m_direction == rtl_Cipher_DirectionInvalid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment