Use p==NULL not !p (in if statements, mainly)

Reviewed-by: Tim Hudson <tjh@openssl.org>
This commit is contained in:
Rich Salz
2015-05-06 13:43:59 -04:00
committed by Rich Salz
parent 344c271eb3
commit 75ebbd9aa4
118 changed files with 754 additions and 724 deletions

View File

@@ -393,7 +393,7 @@ int gost2001_compute_public(EC_KEY *ec)
goto err;
}
BN_CTX_start(ctx);
if (!(priv_key = EC_KEY_get0_private_key(ec))) {
if ((priv_key = EC_KEY_get0_private_key(ec)) == NULL) {
GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_EC_LIB);
goto err;
}

View File

@@ -200,7 +200,7 @@ BIGNUM *gost_get0_priv_key(const EVP_PKEY *pkey)
if (!ec) {
return NULL;
}
if (!(priv = EC_KEY_get0_private_key(ec)))
if ((priv = EC_KEY_get0_private_key(ec)) == NULL)
return NULL;
return (BIGNUM *)priv;
}

View File

@@ -290,28 +290,21 @@ static int ibm_4758_cca_init(ENGINE *e)
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}
#define BINDIT(t, name) (t)DSO_bind_func(dso, name)
# ifndef OPENSSL_NO_RSA
if (!(keyRecordRead = (F_KEYRECORDREAD)
DSO_bind_func(dso, n_keyRecordRead)) ||
!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
DSO_bind_func(dso, n_randomNumberGenerate)) ||
!(digitalSignatureGenerate = (F_DIGITALSIGNATUREGENERATE)
DSO_bind_func(dso, n_digitalSignatureGenerate)) ||
!(digitalSignatureVerify = (F_DIGITALSIGNATUREVERIFY)
DSO_bind_func(dso, n_digitalSignatureVerify)) ||
!(publicKeyExtract = (F_PUBLICKEYEXTRACT)
DSO_bind_func(dso, n_publicKeyExtract)) ||
!(pkaEncrypt = (F_PKAENCRYPT)
DSO_bind_func(dso, n_pkaEncrypt)) || !(pkaDecrypt = (F_PKADECRYPT)
DSO_bind_func(dso,
n_pkaDecrypt)))
if ((keyRecordRead = BINDIT(F_KEYRECORDREAD, n_keyRecordRead)) == NULL
|| (randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL
|| (digitalSignatureGenerate = BINDIT(F_DIGITALSIGNATUREGENERATE, n_digitalSignatureGenerate)) == NULL
|| (digitalSignatureVerify = BINDIT(F_DIGITALSIGNATUREVERIFY, n_digitalSignatureVerify)) == NULL
|| (publicKeyExtract = BINDIT(F_PUBLICKEYEXTRACT, n_publicKeyExtract)) == NULL
|| (pkaEncrypt = BINDIT(F_PKAENCRYPT, n_pkaEncrypt)) == NULL
|| (pkaDecrypt = BINDIT(F_PKADECRYPT, n_pkaDecrypt)) == NULL)
{
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}
# else
if (!(randomNumberGenerate = (F_RANDOMNUMBERGENERATE)
DSO_bind_func(dso, n_randomNumberGenerate))) {
if ((randomNumberGenerate = BINDIT(F_RANDOMNUMBERGENERATE, n_randomNumberGenerate)) == NULL) {
CCA4758err(CCA4758_F_IBM_4758_CCA_INIT, CCA4758_R_DSO_FAILURE);
goto err;
}

View File

@@ -462,22 +462,22 @@ static int aep_init(ENGINE *e)
/* Attempt to load libaep.so. */
aep_dso = DSO_load(NULL, get_AEP_LIBNAME(), NULL, 0);
if (aep_dso == NULL) {
AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED);
goto err;
}
if (!(p1 = (t_AEP_ModExp *) DSO_bind_func(aep_dso, AEP_F1)) ||
!(p2 = (t_AEP_ModExpCrt *) DSO_bind_func(aep_dso, AEP_F2)) ||
#define BINDIT(t, name) (t *)DSO_bind_func(aep_dso, name)
if ((p1 = BINDIT(t_AEP_ModExp, AEP_F1)) == NULL
|| (p2 = BINDIT(t_AEP_ModExpCrt, AEP_F2)) == NULL
# ifdef AEPRAND
!(p3 = (t_AEP_GenRandom *) DSO_bind_func(aep_dso, AEP_F3)) ||
|| (p3 = BINDIT(t_AEP_GenRandom, AEP_F3)) == NULL
# endif
!(p4 = (t_AEP_Finalize *) DSO_bind_func(aep_dso, AEP_F4)) ||
!(p5 = (t_AEP_Initialize *) DSO_bind_func(aep_dso, AEP_F5)) ||
!(p6 = (t_AEP_OpenConnection *) DSO_bind_func(aep_dso, AEP_F6)) ||
!(p7 = (t_AEP_SetBNCallBacks *) DSO_bind_func(aep_dso, AEP_F7)) ||
!(p8 = (t_AEP_CloseConnection *) DSO_bind_func(aep_dso, AEP_F8))) {
|| (p4 = BINDIT(t_AEP_Finalize, AEP_F4)) == NULL
|| (p5 = BINDIT(t_AEP_Initialize, AEP_F5)) == NULL
|| (p6 = BINDIT(t_AEP_OpenConnection, AEP_F6)) == NULL
|| (p7 = BINDIT(t_AEP_SetBNCallBacks, AEP_F7)) == NULL
|| (p8 = BINDIT(t_AEP_CloseConnection, AEP_F8)) == NULL) {
AEPHKerr(AEPHK_F_AEP_INIT, AEPHK_R_NOT_LOADED);
goto err;
}

View File

@@ -382,13 +382,10 @@ static int atalla_init(ENGINE *e)
ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
goto err;
}
if (!
(p1 =
(tfnASI_GetHardwareConfig *) DSO_bind_func(atalla_dso, ATALLA_F1))
|| !(p2 = (tfnASI_RSAPrivateKeyOpFn *) DSO_bind_func(atalla_dso, ATALLA_F2))
|| !(p3 =
(tfnASI_GetPerformanceStatistics *) DSO_bind_func(atalla_dso,
ATALLA_F3))) {
#define BINDIT(t, name) (t *)DSO_bind_func(atalla_dso, name)
if ((p1 = BINDIT(tfnASI_GetHardwareConfig, ATALLA_F1)) == NULL
|| (p2 = BINDIT(tfnASI_RSAPrivateKeyOpFn, ATALLA_F2)) == NULL
|| (p3 = BINDIT(tfnASI_GetPerformanceStatistics, ATALLA_F3)) == NULL) {
ATALLAerr(ATALLA_F_ATALLA_INIT, ATALLA_R_NOT_LOADED);
goto err;
}

View File

@@ -690,7 +690,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
RSA_set_ex_data(rkey, rsa_capi_idx, key);
if (!(ret = EVP_PKEY_new()))
if ((ret = EVP_PKEY_new()) == NULL)
goto memerr;
EVP_PKEY_assign_RSA(ret, rkey);
@@ -735,7 +735,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
DSA_set_ex_data(dkey, dsa_capi_idx, key);
if (!(ret = EVP_PKEY_new()))
if ((ret = EVP_PKEY_new()) == NULL)
goto memerr;
EVP_PKEY_assign_DSA(ret, dkey);
@@ -920,7 +920,7 @@ int capi_rsa_priv_dec(int flen, const unsigned char *from,
}
/* Create temp reverse order version of input */
if (!(tmpbuf = OPENSSL_malloc(flen))) {
if ((tmpbuf = OPENSSL_malloc(flen)) == NULL) {
CAPIerr(CAPI_F_CAPI_RSA_PRIV_DEC, ERR_R_MALLOC_FAILURE);
return -1;
}

View File

@@ -555,26 +555,19 @@ static int hwcrhk_init(ENGINE *e)
HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE);
goto err;
}
if (!(p1 = (HWCryptoHook_Init_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) ||
!(p2 = (HWCryptoHook_Finish_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) ||
!(p3 = (HWCryptoHook_ModExp_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) ||
#define BINDIT(t, name) (t *)DSO_bind_func(hwcrhk_dso, name)
if ((p1 = BINDIT(HWCryptoHook_Init_t, n_hwcrhk_Init)) == NULL
|| (p2 = BINDIT(HWCryptoHook_Finish_t, n_hwcrhk_Finish)) == NULL
|| (p3 = BINDIT(HWCryptoHook_ModExp_t, n_hwcrhk_ModExp)) == NULL
# ifndef OPENSSL_NO_RSA
!(p4 = (HWCryptoHook_RSA_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) ||
!(p5 = (HWCryptoHook_RSALoadKey_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) ||
!(p6 = (HWCryptoHook_RSAGetPublicKey_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) ||
!(p7 = (HWCryptoHook_RSAUnloadKey_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) ||
|| (p4 = BINDIT(HWCryptoHook_RSA_t, n_hwcrhk_RSA)) == NULL
|| (p5 = BINDIT(HWCryptoHook_RSALoadKey_t, n_hwcrhk_RSALoadKey)) == NULL
|| (p6 = BINDIT(HWCryptoHook_RSAGetPublicKey_t, n_hwcrhk_RSAGetPublicKey)) == NULL
|| (p7 = BINDIT(HWCryptoHook_RSAUnloadKey_t, n_hwcrhk_RSAUnloadKey)) == NULL
# endif
!(p8 = (HWCryptoHook_RandomBytes_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) ||
!(p9 = (HWCryptoHook_ModExpCRT_t *)
DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT))) {
|| (p8 = BINDIT(HWCryptoHook_RandomBytes_t, n_hwcrhk_RandomBytes)) == NULL
|| (p9 = BINDIT(HWCryptoHook_ModExpCRT_t, n_hwcrhk_ModExpCRT)) == NULL) {
HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE);
goto err;
}

View File

@@ -404,14 +404,12 @@ static int cswift_init(ENGINE *e)
CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
goto err;
}
if (!(p1 = (t_swAcquireAccContext *)
DSO_bind_func(cswift_dso, CSWIFT_F1)) ||
!(p2 = (t_swAttachKeyParam *)
DSO_bind_func(cswift_dso, CSWIFT_F2)) ||
!(p3 = (t_swSimpleRequest *)
DSO_bind_func(cswift_dso, CSWIFT_F3)) ||
!(p4 = (t_swReleaseAccContext *)
DSO_bind_func(cswift_dso, CSWIFT_F4))) {
#define BINDIT(t, name) (t *)DSO_bind_func(cswift_dso, name)
if ((p1 = BINDIT(t_swAcquireAccContext, CSWIFT_F1)) == NULL
|| (p2 = BINDIT(t_swAttachKeyParam, CSWIFT_F2)) == NULL
|| (p3 = BINDIT(t_swSimpleRequest *) DSO_bind_func(cswift_dso, CSWIFT_F3)) == NULL
|| (p4 = BINDIT(t_swReleaseAccContext *) DSO_bind_func(cswift_dso, CSWIFT_F4)) == NULL) {
CSWIFTerr(CSWIFT_F_CSWIFT_INIT, CSWIFT_R_NOT_LOADED);
goto err;
}

View File

@@ -889,7 +889,7 @@ static int surewarehk_rsa_priv_dec(int flen, const unsigned char *from,
ENGINE_R_NOT_INITIALISED);
}
/* extract ref to private key */
else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_PRIV_DEC,
SUREWARE_R_MISSING_KEY_COMPONENTS);
goto err;
@@ -964,7 +964,7 @@ static int surewarehk_rsa_sign(int flen, const unsigned char *from,
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN, ENGINE_R_NOT_INITIALISED);
}
/* extract ref to private key */
else if (!(hptr = RSA_get_ex_data(rsa, rsaHndidx))) {
else if ((hptr = RSA_get_ex_data(rsa, rsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_RSA_SIGN,
SUREWARE_R_MISSING_KEY_COMPONENTS);
} else {
@@ -1002,7 +1002,7 @@ static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen,
goto err;
}
/* extract ref to private key */
else if (!(hptr = DSA_get_ex_data(dsa, dsaHndidx))) {
else if ((hptr = DSA_get_ex_data(dsa, dsaHndidx)) == NULL) {
SUREWAREerr(SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,
SUREWARE_R_MISSING_KEY_COMPONENTS);
goto err;

View File

@@ -414,38 +414,26 @@ static int ubsec_init(ENGINE *e)
goto err;
}
if (!(p1 = (t_UBSEC_ubsec_bytes_to_bits *)
DSO_bind_func(ubsec_dso, UBSEC_F1))
|| !(p2 = (t_UBSEC_ubsec_bits_to_bytes *)
DSO_bind_func(ubsec_dso, UBSEC_F2))
|| !(p3 = (t_UBSEC_ubsec_open *)
DSO_bind_func(ubsec_dso, UBSEC_F3))
|| !(p4 = (t_UBSEC_ubsec_close *)
DSO_bind_func(ubsec_dso, UBSEC_F4))
#define BINDIT(t, name) (t *)DSO_bind_func(ubsec_dso, name)
if ((p1 = BINDIT(t_UBSEC_ubsec_bytes_to_bits, UBSEC_F1)) == NULL
|| (p2 = BINDIT(t_UBSEC_ubsec_bits_to_bytes, UBSEC_F2)) == NULL
|| (p3 = BINDIT(t_UBSEC_ubsec_open, UBSEC_F3)) == NULL
|| (p4 = BINDIT(t_UBSEC_ubsec_close, UBSEC_F4)) == NULL
# ifndef OPENSSL_NO_DH
|| !(p5 = (t_UBSEC_diffie_hellman_generate_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F5))
|| !(p6 = (t_UBSEC_diffie_hellman_agree_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F6))
|| (p5 = BINDIT(t_UBSEC_diffie_hellman_generate_ioctl, UBSEC_F5)) == NULL
|| (p6 = BINDIT(t_UBSEC_diffie_hellman_agree_ioctl, UBSEC_F6)) == NULL
# endif
/* #ifndef OPENSSL_NO_RSA */
|| !(p7 = (t_UBSEC_rsa_mod_exp_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F7))
|| !(p8 = (t_UBSEC_rsa_mod_exp_crt_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F8))
|| (p7 = BINDIT(t_UBSEC_rsa_mod_exp_ioctl, UBSEC_F7)) == NULL
|| (p8 = BINDIT(t_UBSEC_rsa_mod_exp_crt_ioctl, UBSEC_F8)) == NULL
/* #endif */
# ifndef OPENSSL_NO_DSA
|| !(p9 = (t_UBSEC_dsa_sign_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F9))
|| !(p10 = (t_UBSEC_dsa_verify_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F10))
|| (p9 = BINDIT(t_UBSEC_dsa_sign_ioctl, UBSEC_F9)) == NULL
|| (p10 = BINDIT(t_UBSEC_dsa_verify_ioctl, UBSEC_F10)) == NULL
# endif
|| !(p11 = (t_UBSEC_math_accelerate_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F11))
|| !(p12 = (t_UBSEC_rng_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F12))
|| !(p13 = (t_UBSEC_max_key_len_ioctl *)
DSO_bind_func(ubsec_dso, UBSEC_F13))) {
|| (p11 = BINDIT(t_UBSEC_math_accelerate_ioctl, UBSEC_F11)) == NULL
|| (p12 = BINDIT(t_UBSEC_rng_ioctl, UBSEC_F12)) == NULL
|| (p13 = BINDIT(t_UBSEC_max_key_len_ioctl, UBSEC_F13)) == NULL) {
UBSECerr(UBSEC_F_UBSEC_INIT, UBSEC_R_DSO_FAILURE);
goto err;
}