From 004e0f600266d411435a18565a49d38e4bb49291 Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Fri, 18 Oct 2024 18:03:46 +0000 Subject: Simplify EC_get_builtin_curves(). When determining the minimum of nitems and EC_CURVE_LIST_LENGTH we need neither an extra variable nor a ternary operator. --- lib/libcrypto/ec/ec_curve.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libcrypto/ec/ec_curve.c b/lib/libcrypto/ec/ec_curve.c index 4c1611f1af0..6d7eea81cf8 100644 --- a/lib/libcrypto/ec/ec_curve.c +++ b/lib/libcrypto/ec/ec_curve.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_curve.c,v 1.45 2024/10/18 17:56:45 tb Exp $ */ +/* $OpenBSD: ec_curve.c,v 1.46 2024/10/18 18:03:45 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -2680,14 +2680,15 @@ ec_group_is_builtin_curve(const EC_GROUP *group) size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems) { - size_t i, min; + size_t i; if (r == NULL || nitems == 0) return EC_CURVE_LIST_LENGTH; - min = nitems < EC_CURVE_LIST_LENGTH ? nitems : EC_CURVE_LIST_LENGTH; + if (nitems > EC_CURVE_LIST_LENGTH) + nitems = EC_CURVE_LIST_LENGTH; - for (i = 0; i < min; i++) { + for (i = 0; i < nitems; i++) { r[i].nid = ec_curve_list[i].nid; r[i].comment = ec_curve_list[i].comment; } -- cgit v1.2.3