2
0
Эх сурвалжийг харах

unwind conditional expressions

I prefer readability
Steffen Jaeckel 11 жил өмнө
parent
commit
800182338e

+ 14 - 2
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;
          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 */
          /* constructed, use the 'used' field to store the original tag number */
          l->used = (type & 0x1F);
          l->used = (type & 0x1F);
          /* treat constructed elements like SETs */
          /* treat constructed elements like SETs */
          type = 0x31;
          type = 0x31;
       }
       }
+      else {
+         is_constructed = 0;
+      }
 
 
      /* now switch on type */
      /* now switch on type */
       switch (type) {
       switch (type) {
@@ -332,7 +336,15 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
          case 0x31: /* SET */
          case 0x31: /* SET */
 
 
              /* init field */
              /* 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 */
              /* we have to decode the SEQUENCE header and get it's length */