]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Uniform TEST_*() check usage in test/ectest.c
authorNicola Tuveri <nic.tuv@gmail.com>
Mon, 9 Sep 2019 01:00:37 +0000 (04:00 +0300)
committerNicola Tuveri <nic.tuv@gmail.com>
Mon, 9 Sep 2019 11:44:47 +0000 (14:44 +0300)
- 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)

test/ectest.c

index 2334432bccc316007a6f446082bb987059d75ef3..4f3bfb7569c3816d887b5dd82dde3fa568bdbea2 100644 (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;
 
     /*