summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-05-06 13:43:59 -0400
committerRich Salz <rsalz@openssl.org>2015-05-11 10:06:38 -0400
commit75ebbd9aa411c5b8b19ded6ace2b34181566b56a (patch)
tree6bc9cd77b2794b25f9cd9aac1c66f4626fb975a5 /demos
parent344c271eb339fc2982e9a3584a94e51112d84584 (diff)
Use p==NULL not !p (in if statements, mainly)
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'demos')
-rw-r--r--demos/engines/cluster_labs/hw_cluster_labs.c29
-rw-r--r--demos/engines/ibmca/hw_ibmca.c10
-rw-r--r--demos/engines/zencod/hw_zencod.c70
-rw-r--r--demos/pkcs12/pkread.c4
-rw-r--r--demos/pkcs12/pkwrite.c4
5 files changed, 47 insertions, 70 deletions
diff --git a/demos/engines/cluster_labs/hw_cluster_labs.c b/demos/engines/cluster_labs/hw_cluster_labs.c
index 918689c215..e1f251c336 100644
--- a/demos/engines/cluster_labs/hw_cluster_labs.c
+++ b/demos/engines/cluster_labs/hw_cluster_labs.c
@@ -319,23 +319,18 @@ int cluster_labs_init(ENGINE *e)
goto err;
}
/* bind functions */
- if (!
- (p1 =
- (cl_engine_init *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F1))
-|| !(p2 = (cl_mod_exp *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F2))
-|| !(p3 = (cl_mod_exp_crt *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F3))
-|| !(p4 = (cl_rsa_mod_exp *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F4))
-|| !(p5 =
- (cl_rsa_priv_enc *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F5))
-|| !(p6 =
- (cl_rsa_priv_dec *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F6))
-|| !(p7 = (cl_rsa_pub_enc *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F7))
-|| !(p8 = (cl_rsa_pub_dec *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F8))
-|| !(p20 =
- (cl_rand_bytes *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F20))
-|| !(p30 = (cl_dsa_sign *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F30))
-|| !(p31 =
- (cl_dsa_verify *) DSO_bind_func(cluster_labs_dso, CLUSTER_LABS_F31))) {
+#define BINDIT(t, name) (t *)DSO_bind_func(cluster_labs_dso, name)
+ if ((p1 = (cl_engine_init, CLUSTER_LABS_F1)) == NULL
+ || (p2 = BINDIT(cl_mod_exp, CLUSTER_LABS_F2)) == NULL
+ || (p3 = BINDIT(cl_mod_exp_crt, CLUSTER_LABS_F3)) == NULL
+ || (p4 = BINDIT(cl_rsa_mod_exp, CLUSTER_LABS_F4)) == NULL
+ || (p5 = BINDIT(cl_rsa_priv_enc, CLUSTER_LABS_F5)) == NULL
+ || (p6 = BINDIT(cl_rsa_priv_dec, CLUSTER_LABS_F6)) == NULL
+ || (p7 = BINDIT(cl_rsa_pub_enc, CLUSTER_LABS_F7)) == NULL
+ || (p8 = BINDIT(cl_rsa_pub_dec, CLUSTER_LABS_F8)) == NULL
+ || (p20 = BINDIT(cl_rand_bytes, CLUSTER_LABS_F20)) == NULL
+ || (p30 = BINDIT(cl_dsa_sign, CLUSTER_LABS_F30)) == NULL
+ || (p31 = BINDIT(cl_dsa_verify, CLUSTER_LABS_F31)) == NULL) {
CLerr(CL_F_CLUSTER_LABS_INIT, CL_R_DSO_FAILURE);
goto err;
}
diff --git a/demos/engines/ibmca/hw_ibmca.c b/demos/engines/ibmca/hw_ibmca.c
index 5017d6490d..29f8547698 100644
--- a/demos/engines/ibmca/hw_ibmca.c
+++ b/demos/engines/ibmca/hw_ibmca.c
@@ -388,11 +388,11 @@ static int ibmca_init(ENGINE *e)
goto err;
}
- if (!(p1 = DSO_bind_func(ibmca_dso, IBMCA_F1)) ||
- !(p2 = DSO_bind_func(ibmca_dso, IBMCA_F2)) ||
- !(p3 = DSO_bind_func(ibmca_dso, IBMCA_F3)) ||
- !(p4 = DSO_bind_func(ibmca_dso, IBMCA_F4)) ||
- !(p5 = DSO_bind_func(ibmca_dso, IBMCA_F5))) {
+ if ((p1 = DSO_bind_func(ibmca_dso, IBMCA_F1)) == NULL
+ || (p2 = DSO_bind_func(ibmca_dso, IBMCA_F2)) == NULL
+ || (p3 = DSO_bind_func(ibmca_dso, IBMCA_F3)) == NULL
+ || (p4 = DSO_bind_func(ibmca_dso, IBMCA_F4)) == NULL
+ || (p5 = DSO_bind_func(ibmca_dso, IBMCA_F5)) == NULL) {
IBMCAerr(IBMCA_F_IBMCA_INIT, IBMCA_R_DSO_FAILURE);
goto err;
}
diff --git a/demos/engines/zencod/hw_zencod.c b/demos/engines/zencod/hw_zencod.c
index 773674f444..f13cf37522 100644
--- a/demos/engines/zencod/hw_zencod.c
+++ b/demos/engines/zencod/hw_zencod.c
@@ -538,46 +538,28 @@ static int zencod_init(ENGINE *e)
/*
* Trying to load Function from the Library
*/
- if (!
- (ptr_1 =
- (t_zencod_bytes2bits *) DSO_bind_func(zencod_dso, ZENCOD_Fct_1))
-|| !(ptr_2 = (t_zencod_bits2bytes *) DSO_bind_func(zencod_dso, ZENCOD_Fct_2))
-|| !(ptr_3 = (t_zencod_new_number *) DSO_bind_func(zencod_dso, ZENCOD_Fct_3))
-|| !(ptr_4 = (t_zencod_init_number *) DSO_bind_func(zencod_dso, ZENCOD_Fct_4))
-|| !(ptr_exp_1 =
- (t_zencod_rsa_mod_exp *) DSO_bind_func(zencod_dso, ZENCOD_Fct_exp_1))
-|| !(ptr_exp_2 =
- (t_zencod_rsa_mod_exp_crt *) DSO_bind_func(zencod_dso, ZENCOD_Fct_exp_2))
-|| !(ptr_dsa_1 =
- (t_zencod_dsa_do_sign *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dsa_1))
-|| !(ptr_dsa_2 =
- (t_zencod_dsa_do_verify *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dsa_2))
-|| !(ptr_dh_1 =
- (t_zencod_dh_generate_key *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dh_1))
-|| !(ptr_dh_2 =
- (t_zencod_dh_compute_key *) DSO_bind_func(zencod_dso, ZENCOD_Fct_dh_2))
-|| !(ptr_rand_1 =
- (t_zencod_rand_bytes *) DSO_bind_func(zencod_dso, ZENCOD_Fct_rand_1))
-|| !(ptr_math_1 =
- (t_zencod_math_mod_exp *) DSO_bind_func(zencod_dso, ZENCOD_Fct_math_1))
-|| !(ptr_0 = (t_zencod_test *) DSO_bind_func(zencod_dso, ZENCOD_Fct_0))
-|| !(ptr_md5_1 =
- (t_zencod_md5_init *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_1))
-|| !(ptr_md5_2 =
- (t_zencod_md5_update *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_2))
-|| !(ptr_md5_3 =
- (t_zencod_md5_do_final *) DSO_bind_func(zencod_dso, ZENCOD_Fct_md5_3))
-|| !(ptr_sha1_1 =
- (t_zencod_sha1_init *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_1))
-|| !(ptr_sha1_2 =
- (t_zencod_sha1_update *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_2))
-|| !(ptr_sha1_3 =
- (t_zencod_sha1_do_final *) DSO_bind_func(zencod_dso, ZENCOD_Fct_sha1_3))
-|| !(ptr_xdes_1 =
- (t_zencod_xdes_cipher *) DSO_bind_func(zencod_dso, ZENCOD_Fct_xdes_1))
-|| !(ptr_rc4_1 =
- (t_zencod_rc4_cipher *) DSO_bind_func(zencod_dso, ZENCOD_Fct_rc4_1))) {
-
+#define BINDIT(t, name) (t*)DSO_bindfunc(zencod_dso, name)
+ if ((ptr_1 = BINDIT(t_zencod_bytes2bits ZENCOD_Fct_1)) == NULL
+ || (ptr_2 = BINDIT(t_zencod_bits2bytes ZENCOD_Fct_2)) == NULL
+ || (ptr_3 = BINDIT(t_zencod_new_number ZENCOD_Fct_3)) == NULL
+ || (ptr_4 = BINDIT(t_zencod_init_number ZENCOD_Fct_4)) == NULL
+ || (ptr_exp_1 = BINDIT(t_zencod_rsa_mod_exp, ZENCOD_Fct_exp_1)) == NULL
+ || (ptr_exp_2 = BINDIT(t_zencod_rsa_mod_exp_crt, ZENCOD_Fct_exp_2)) == NULL
+ || (ptr_dsa_1 = BINDIT(t_zencod_dsa_do_sign, ZENCOD_Fct_dsa_1)) == NULL
+ || (ptr_dsa_2 = BINDIT(t_zencod_dsa_do_verify, ZENCOD_Fct_dsa_2)) == NULL
+ || (ptr_dh_1 = BINDIT(t_zencod_dh_generate_key, ZENCOD_Fct_dh_1)) == NULL
+ || (ptr_dh_2 = BINDIT(t_zencod_dh_compute_key, ZENCOD_Fct_dh_2)) == NULL
+ || (ptr_rand_1 = BINDIT(t_zencod_rand_bytes, ZENCOD_Fct_rand_1)) == NULL
+ || (ptr_math_1 = BINDIT(t_zencod_math_mod_exp, ZENCOD_Fct_math_1)) == NULL
+ || (ptr_0 = BINDIT(t_zencod_test, ZENCOD_Fct_0)) == NULL
+ || (ptr_md5_1 = BINDIT(t_zencod_md5_init, ZENCOD_Fct_md5_1)) == NULL
+ || (ptr_md5_2 = BINDIT(t_zencod_md5_update, ZENCOD_Fct_md5_2)) == NULL
+ || (ptr_md5_3 = BINDIT(t_zencod_md5_do_final, ZENCOD_Fct_md5_3)) == NULL
+ || (ptr_sha1_1 = BINDIT(t_zencod_sha1_init, ZENCOD_Fct_sha1_1)) == NULL
+ || (ptr_sha1_2 = BINDIT(t_zencod_sha1_update, ZENCOD_Fct_sha1_2)) == NULL
+ || (ptr_sha1_3 = BINDIT(t_zencod_sha1_do_final, ZENCOD_Fct_sha1_3)) == NULL
+ || (ptr_xdes_1 = BINDIT(t_zencod_xdes_cipher, ZENCOD_Fct_xdes_1)) == NULL
+ || (ptr_rc4_1 = BINDIT(t_zencod_rc4_cipher, ZENCOD_Fct_rc4_1)) == NULL) {
ZENCODerr(ZENCOD_F_ZENCOD_INIT, ZENCOD_R_DSO_FAILURE);
goto err;
}
@@ -906,7 +888,7 @@ static DSA_SIG *DSA_zencod_do_sign(const unsigned char *dgst, int dlen,
return meth->dsa_do_sign(dgst, dlen, dsa);
}
- if (!(bn_s = BN_new()) || !(bn_r = BN_new())) {
+ if ((bn_s = BN_new()) == NULL || (bn_r = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_BAD_KEY_COMPONENTS);
goto FAILED;
}
@@ -935,7 +917,7 @@ static DSA_SIG *DSA_zencod_do_sign(const unsigned char *dgst, int dlen,
goto FAILED;
}
- if (!(sig = DSA_SIG_new())) {
+ if ((sig = DSA_SIG_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DSA_DO_SIGN, ZENCOD_R_REQUEST_FAILED);
goto FAILED;
}
@@ -1032,7 +1014,7 @@ static int DH_zencod_generate_key(DH *dh)
bn_prv = dh->priv_key;
generate_x = 0;
} else {
- if (!(bn_prv = BN_new())) {
+ if ((bn_prv = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);
goto FAILED;
}
@@ -1042,7 +1024,7 @@ static int DH_zencod_generate_key(DH *dh)
/* Public key */
if (dh->pub_key)
bn_pub = dh->pub_key;
- else if (!(bn_pub = BN_new())) {
+ else if ((bn_pub = BN_new()) == NULL) {
ENGINEerr(ZENCOD_F_ZENCOD_DH_GENERATE, ZENCOD_R_BN_EXPAND_FAIL);
goto FAILED;
}
diff --git a/demos/pkcs12/pkread.c b/demos/pkcs12/pkread.c
index f4a3df4079..1086dbc463 100644
--- a/demos/pkcs12/pkread.c
+++ b/demos/pkcs12/pkread.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
}
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
- if (!(fp = fopen(argv[1], "rb"))) {
+ if ((fp = fopen(argv[1], "rb")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
@@ -39,7 +39,7 @@ int main(int argc, char **argv)
exit(1);
}
PKCS12_free(p12);
- if (!(fp = fopen(argv[3], "w"))) {
+ if ((fp = fopen(argv[3], "w")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
diff --git a/demos/pkcs12/pkwrite.c b/demos/pkcs12/pkwrite.c
index fed773ea76..34e82dd6b9 100644
--- a/demos/pkcs12/pkwrite.c
+++ b/demos/pkcs12/pkwrite.c
@@ -20,7 +20,7 @@ int main(int argc, char **argv)
}
SSLeay_add_all_algorithms();
ERR_load_crypto_strings();
- if (!(fp = fopen(argv[1], "r"))) {
+ if ((fp = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
exit(1);
}
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
ERR_print_errors_fp(stderr);
exit(1);
}
- if (!(fp = fopen(argv[4], "wb"))) {
+ if ((fp = fopen(argv[4], "wb")) == NULL) {
fprintf(stderr, "Error opening file %s\n", argv[1]);
ERR_print_errors_fp(stderr);
exit(1);