Skip to content

Commit

Permalink
Correct the logic in switch() cases order for OCTET_STRING_aper
Browse files Browse the repository at this point in the history
  • Loading branch information
mouse07410 committed Aug 18, 2024
1 parent b798215 commit fc78563
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions skeletons/OCTET_STRING_aper.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
}

switch(specs->subvariant) {
default:
/*
case ASN_OSUBV_ANY:
ASN_DEBUG("Unrecognized subvariant %d", specs->subvariant);
RETURN(RC_FAIL);
*/
case ASN_OSUBV_BIT:
canonical_unit_bits = unit_bits = 1;
bpc = OS__BPC_BIT;
break;
case ASN_OSUBV_ANY:
case ASN_OSUBV_STR:
canonical_unit_bits = unit_bits = 8;
Expand All @@ -88,6 +78,16 @@ OCTET_STRING_decode_aper(const asn_codec_ctx_t *opt_codec_ctx,
unit_bits = cval->range_bits;
bpc = OS__BPC_U32;
break;
/*
case ASN_OSUBV_ANY:
ASN_DEBUG("Unrecognized subvariant %d", specs->subvariant);
RETURN(RC_FAIL);
*/
case ASN_OSUBV_BIT:
default:
canonical_unit_bits = unit_bits = 1;
bpc = OS__BPC_BIT;
break;
}

/*
Expand Down Expand Up @@ -266,19 +266,7 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
ct_extensible = csiz->flags & APC_EXTENSIBLE;

switch(specs->subvariant) {
default:
/*
case ASN_OSUBV_ANY:
ASN__ENCODE_FAILED;
*/
case ASN_OSUBV_BIT:
canonical_unit_bits = unit_bits = 1;
bpc = OS__BPC_BIT;
sizeinunits = st->size * 8 - (st->bits_unused & 0x07);
ASN_DEBUG("BIT STRING of %d bytes",
sizeinunits);
break;
case ASN_OSUBV_ANY:
case ASN_OSUBV_ANY:
case ASN_OSUBV_STR:
canonical_unit_bits = unit_bits = 8;
/*
Expand All @@ -302,6 +290,18 @@ OCTET_STRING_encode_aper(const asn_TYPE_descriptor_t *td,
bpc = OS__BPC_U32;
sizeinunits = st->size / 4;
break;
/*
case ASN_OSUBV_ANY:
ASN__ENCODE_FAILED;
*/
case ASN_OSUBV_BIT:
default:
canonical_unit_bits = unit_bits = 1;
bpc = OS__BPC_BIT;
sizeinunits = st->size * 8 - (st->bits_unused & 0x07);
ASN_DEBUG("BIT STRING of %d bytes",
sizeinunits);
break;
}

ASN_DEBUG("Encoding %s into %d units of %d bits"
Expand Down

0 comments on commit fc78563

Please sign in to comment.