Uniform TEST_*() check usage in test/ectest.c

- Replace a `TEST_true()` with `!TEST_false()` to avoid reporting
  confusing errors
- We tend to use `if (!TEST_foo() || !TEST_bar())` and it's a bit
  confusing to switch to `if(!(TEST_foo() && TEST_bar()))`: replace it
  with the more common style

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/9813)
This commit is contained in:
Nicola Tuveri 2019-09-09 04:00:37 +03:00
parent 65936a5646
commit bfed4fc836

View File

@ -1679,8 +1679,8 @@ static int check_named_curve_test(int id)
group_cofactor))
|| !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0, NULL), 0)
/* The order is not an optional field, so this should fail */
|| TEST_true(EC_GROUP_set_generator(gtest, group_gen, NULL,
group_cofactor))
|| !TEST_false(EC_GROUP_set_generator(gtest, group_gen, NULL,
group_cofactor))
|| !TEST_true(EC_GROUP_set_generator(gtest, group_gen, group_order,
other_cofactor))
|| !TEST_int_eq(EC_GROUP_check_named_curve(gtest, 0, NULL), 0)
@ -2214,17 +2214,17 @@ static int check_ec_key_field_public_range_test(int id)
BIGNUM *x = NULL, *y = NULL;
EC_KEY *key = NULL;
if (!(TEST_ptr(x = BN_new())
&& TEST_ptr(y = BN_new())
&& TEST_ptr(key = EC_KEY_new_by_curve_name(curves[id].nid))
&& TEST_ptr(group = EC_KEY_get0_group(key))
&& TEST_ptr(meth = EC_GROUP_method_of(group))
&& TEST_ptr(field = EC_GROUP_get0_field(group))
&& TEST_int_gt(EC_KEY_generate_key(key), 0)
&& TEST_int_gt(EC_KEY_check_key(key), 0)
&& TEST_ptr(pub = EC_KEY_get0_public_key(key))
&& TEST_int_gt(EC_POINT_get_affine_coordinates(group, pub, x, y,
NULL), 0)))
if (!TEST_ptr(x = BN_new())
|| !TEST_ptr(y = BN_new())
|| !TEST_ptr(key = EC_KEY_new_by_curve_name(curves[id].nid))
|| !TEST_ptr(group = EC_KEY_get0_group(key))
|| !TEST_ptr(meth = EC_GROUP_method_of(group))
|| !TEST_ptr(field = EC_GROUP_get0_field(group))
|| !TEST_int_gt(EC_KEY_generate_key(key), 0)
|| !TEST_int_gt(EC_KEY_check_key(key), 0)
|| !TEST_ptr(pub = EC_KEY_get0_public_key(key))
|| !TEST_int_gt(EC_POINT_get_affine_coordinates(group, pub, x, y,
NULL), 0))
goto err;
/*