From b959995f22ee927d8893439f5fff6711b8f5725e Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Tue, 4 Jan 2022 20:52:35 +0000 Subject: Readability tweaks in the print helper i2r_IPAddressOrRanges. Assign repeated nested expressions to local variables and avoid some awkward line wrapping. --- lib/libcrypto/x509/x509_addr.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lib/libcrypto') diff --git a/lib/libcrypto/x509/x509_addr.c b/lib/libcrypto/x509/x509_addr.c index d2de8dc2aa2..edb85f34939 100644 --- a/lib/libcrypto/x509/x509_addr.c +++ b/lib/libcrypto/x509/x509_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_addr.c,v 1.57 2022/01/04 20:40:43 tb Exp $ */ +/* $OpenBSD: x509_addr.c,v 1.58 2022/01/04 20:52:34 tb Exp $ */ /* * Contributed to the OpenSSL Project by the American Registry for * Internet Numbers ("ARIN"). @@ -567,29 +567,37 @@ static int i2r_IPAddressOrRanges(BIO *out, const int indent, const IPAddressOrRanges *aors, const unsigned afi) { + const IPAddressOrRange *aor; + const ASN1_BIT_STRING *prefix; + const IPAddressRange *range; int i; + for (i = 0; i < sk_IPAddressOrRange_num(aors); i++) { - const IPAddressOrRange *aor = sk_IPAddressOrRange_value(aors, i); + aor = sk_IPAddressOrRange_value(aors, i); + BIO_printf(out, "%*s", indent, ""); + switch (aor->type) { case IPAddressOrRange_addressPrefix: - if (!i2r_address(out, afi, 0x00, aor->u.addressPrefix)) + prefix = aor->u.addressPrefix; + + if (!i2r_address(out, afi, 0x00, prefix)) return 0; - BIO_printf(out, "/%d\n", - addr_prefix_len(aor->u.addressPrefix)); + BIO_printf(out, "/%d\n", addr_prefix_len(prefix)); continue; case IPAddressOrRange_addressRange: - if (!i2r_address(out, afi, 0x00, - aor->u.addressRange->min)) + range = aor->u.addressRange; + + if (!i2r_address(out, afi, 0x00, range->min)) return 0; BIO_puts(out, "-"); - if (!i2r_address(out, afi, 0xff, - aor->u.addressRange->max)) + if (!i2r_address(out, afi, 0xff, range->max)) return 0; BIO_puts(out, "\n"); continue; } } + return 1; } -- cgit v1.2.3