From: jsing Date: Fri, 3 Dec 2021 17:03:54 +0000 (+0000) Subject: Rewrite ASN1_STRING_cmp(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ce3d60d308519ea7a1508c2d600de8f8fbae9d82;p=openbsd Rewrite ASN1_STRING_cmp(). This removes nested ifs and uses more sensible variable names. ok schwarze@ tb@ --- diff --git a/lib/libcrypto/asn1/asn1_lib.c b/lib/libcrypto/asn1/asn1_lib.c index 0998b418290..3e2ba29495e 100644 --- a/lib/libcrypto/asn1/asn1_lib.c +++ b/lib/libcrypto/asn1/asn1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_lib.c,v 1.47 2021/12/03 17:01:07 jsing Exp $ */ +/* $OpenBSD: asn1_lib.c,v 1.48 2021/12/03 17:03:54 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -383,19 +383,16 @@ ASN1_STRING_free(ASN1_STRING *a) int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) { - int i; + int cmp; if (a == NULL || b == NULL) return -1; - i = (a->length - b->length); - if (i == 0) { - i = memcmp(a->data, b->data, a->length); - if (i == 0) - return (a->type - b->type); - else - return (i); - } else - return (i); + if ((cmp = (a->length - b->length)) != 0) + return cmp; + if ((cmp = memcmp(a->data, b->data, a->length)) != 0) + return cmp; + + return (a->type - b->type); } void