From 800182338e0e9fa573c8b73f6199c237cce09525 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Sat, 23 Aug 2014 20:19:51 +0200 Subject: [PATCH] unwind conditional expressions I prefer readability --- .../der/sequence/der_decode_sequence_flexi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c b/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c index c074448..8bd3b5d 100644 --- a/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c +++ b/src/pk/asn1/der/sequence/der_decode_sequence_flexi.c @@ -103,12 +103,16 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc l = l->next; } - if ((is_constructed = (((type & 0x20) && type != 0x30 && type != 0x31) ? 1 : 0))) { + if ((type & 0x20) && (type != 0x30) && (type != 0x31)) { + is_constructed = 1; /* constructed, use the 'used' field to store the original tag number */ l->used = (type & 0x1F); /* treat constructed elements like SETs */ type = 0x31; } + else { + is_constructed = 0; + } /* now switch on type */ switch (type) { @@ -332,7 +336,15 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc case 0x31: /* SET */ /* init field */ - l->type = (is_constructed ? LTC_ASN1_CONSTRUCTED : ((type == 0x30) ? LTC_ASN1_SEQUENCE : LTC_ASN1_SET)); + if (is_constructed) { + l->type = LTC_ASN1_CONSTRUCTED; + } + else if (type == 0x30) { + l->type = LTC_ASN1_SEQUENCE; + } + else { + l->type = LTC_ASN1_SET; + } /* we have to decode the SEQUENCE header and get it's length */