diff options
| author | jsing <> | 2021-12-03 17:03:54 +0000 |
|---|---|---|
| committer | jsing <> | 2021-12-03 17:03:54 +0000 |
| commit | a05caa4b1095f3e3b19bc239c1d4ae8506cea005 (patch) | |
| tree | a34e2401e349e408d0b12e9bc0003ec70827c982 /src/lib | |
| parent | af38d2832bcd4b2f0397b3f018c3a38fac16d164 (diff) | |
| download | openbsd-a05caa4b1095f3e3b19bc239c1d4ae8506cea005.tar.gz openbsd-a05caa4b1095f3e3b19bc239c1d4ae8506cea005.tar.bz2 openbsd-a05caa4b1095f3e3b19bc239c1d4ae8506cea005.zip | |
Rewrite ASN1_STRING_cmp().
This removes nested ifs and uses more sensible variable names.
ok schwarze@ tb@
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/libcrypto/asn1/asn1_lib.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_lib.c b/src/lib/libcrypto/asn1/asn1_lib.c index 0998b41829..3e2ba29495 100644 --- a/src/lib/libcrypto/asn1/asn1_lib.c +++ b/src/lib/libcrypto/asn1/asn1_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: asn1_lib.c,v 1.47 2021/12/03 17:01:07 jsing Exp $ */ | 1 | /* $OpenBSD: asn1_lib.c,v 1.48 2021/12/03 17:03:54 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -383,19 +383,16 @@ ASN1_STRING_free(ASN1_STRING *a) | |||
| 383 | int | 383 | int |
| 384 | ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) | 384 | ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b) |
| 385 | { | 385 | { |
| 386 | int i; | 386 | int cmp; |
| 387 | 387 | ||
| 388 | if (a == NULL || b == NULL) | 388 | if (a == NULL || b == NULL) |
| 389 | return -1; | 389 | return -1; |
| 390 | i = (a->length - b->length); | 390 | if ((cmp = (a->length - b->length)) != 0) |
| 391 | if (i == 0) { | 391 | return cmp; |
| 392 | i = memcmp(a->data, b->data, a->length); | 392 | if ((cmp = memcmp(a->data, b->data, a->length)) != 0) |
| 393 | if (i == 0) | 393 | return cmp; |
| 394 | return (a->type - b->type); | 394 | |
| 395 | else | 395 | return (a->type - b->type); |
| 396 | return (i); | ||
| 397 | } else | ||
| 398 | return (i); | ||
| 399 | } | 396 | } |
| 400 | 397 | ||
| 401 | void | 398 | void |
