diff mbox series

[API-NEXT,v5,17/23] test: odp_crypto: bail out if odp_crypto_session_create failed

Message ID 20170601090339.9313-18-dmitry.ereminsolenikov@linaro.org
State New
Headers show
Series Major cryptography code rework | expand

Commit Message

Dmitry Eremin-Solenikov June 1, 2017, 9:03 a.m. UTC
If odp_crypto_session_create() failed, there is no point in
checking/freeing session, as it might not have been updated.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
 test/common_plat/performance/odp_crypto.c | 44 +++++++++++++++----------------
 1 file changed, 21 insertions(+), 23 deletions(-)

-- 
2.11.0
diff mbox series

Patch

diff --git a/test/common_plat/performance/odp_crypto.c b/test/common_plat/performance/odp_crypto.c
index 6a58294a25ff..c3dd6d38f3cb 100644
--- a/test/common_plat/performance/odp_crypto.c
+++ b/test/common_plat/performance/odp_crypto.c
@@ -665,34 +665,32 @@  run_measure_one_config(crypto_args_t *cargs,
 	int rc = 0;
 
 	if (create_session_from_config(&session, config, cargs))
-		rc = -1;
-
-	if (!rc) {
-		if (cargs->payload_length) {
-			rc = run_measure_one(cargs, config, &session,
-					     cargs->payload_length, &result);
-			if (!rc) {
-				print_result_header();
-				print_result(cargs, cargs->payload_length,
-					     config, &result);
-			}
-		} else {
-			unsigned i;
+		return -1;
 
+	if (cargs->payload_length) {
+		rc = run_measure_one(cargs, config, &session,
+				     cargs->payload_length, &result);
+		if (!rc) {
 			print_result_header();
-			for (i = 0; i < num_payloads; i++) {
-				rc = run_measure_one(cargs, config, &session,
-						     payloads[i], &result);
-				if (rc)
-					break;
-				print_result(cargs, payloads[i],
-					     config, &result);
-			}
+			print_result(cargs, cargs->payload_length,
+				     config, &result);
+		}
+	} else {
+		unsigned i;
+
+		print_result_header();
+		for (i = 0; i < num_payloads; i++) {
+			rc = run_measure_one(cargs, config, &session,
+					     payloads[i], &result);
+			if (rc)
+				break;
+			print_result(cargs, payloads[i],
+				     config, &result);
 		}
 	}
 
-	if (session != ODP_CRYPTO_SESSION_INVALID)
-		odp_crypto_session_destroy(session);
+	odp_crypto_session_destroy(session);
+
 	return rc;
 }