From: tb Date: Sat, 1 Apr 2023 12:44:56 +0000 (+0000) Subject: Pull static const data out of BN_value_one() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=05633f8622c7ca2ec993bbb49b8324988d6be874;p=openbsd Pull static const data out of BN_value_one() Also use C99 initializers for readability. discussed with jsing --- diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index 980c9b54570..3ca2b7f14b0 100644 --- a/lib/libcrypto/bn/bn_lib.c +++ b/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.79 2023/03/31 19:39:15 tb Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.80 2023/04/01 12:44:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -209,15 +209,19 @@ BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) dest->flags = dest_flags; } +static const BN_ULONG bn_value_one_data = 1; +static const BIGNUM bn_value_one = { + .d = (BN_ULONG *)&bn_value_one_data, + .top = 1, + .dmax = 1, + .neg = 0, + .flags = BN_FLG_STATIC_DATA, +}; + const BIGNUM * BN_value_one(void) { - static const BN_ULONG data_one = 1L; - static const BIGNUM const_one = { - (BN_ULONG *)&data_one, 1, 1, 0, BN_FLG_STATIC_DATA - }; - - return (&const_one); + return &bn_value_one; } #ifndef HAVE_BN_WORD_CLZ