Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
8282f80b
Commit
8282f80b
authored
Oct 27, 2021
by
Raphael Riebl
Committed by
Mouse
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
INTEGER_uper: tidy up use of (u)intmax_t at encoding
parent
fe2c1f69
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
skeletons/INTEGER_uper.c
skeletons/INTEGER_uper.c
+21
-20
No files found.
skeletons/INTEGER_uper.c
View file @
8282f80b
...
@@ -134,7 +134,10 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -134,7 +134,10 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
const
uint8_t
*
buf
;
const
uint8_t
*
buf
;
const
uint8_t
*
end
;
const
uint8_t
*
end
;
const
asn_per_constraint_t
*
ct
;
const
asn_per_constraint_t
*
ct
;
intmax_t
value
=
0
;
union
{
intmax_t
s
;
uintmax_t
u
;
}
value
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
if
(
!
st
||
st
->
size
==
0
)
ASN__ENCODE_FAILED
;
...
@@ -146,37 +149,35 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -146,37 +149,35 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
if
(
ct
)
{
if
(
ct
)
{
int
inext
=
0
;
int
inext
=
0
;
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
uintmax_t
uval
;
if
(
asn_INTEGER2umax
(
st
,
&
value
.
u
))
if
(
asn_INTEGER2umax
(
st
,
&
uval
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
uval
<
(
uintmax_t
)
ct
->
lower_bound
)
if
(
value
.
u
<
(
uintmax_t
)
ct
->
lower_bound
)
inext
=
1
;
inext
=
1
;
}
else
if
(
ct
->
range_bits
>=
0
)
{
}
else
if
(
ct
->
range_bits
>=
0
)
{
if
(
uval
<
(
uintmax_t
)
ct
->
lower_bound
if
(
value
.
u
<
(
uintmax_t
)
ct
->
lower_bound
||
uval
>
(
uintmax_t
)
ct
->
upper_bound
)
||
value
.
u
>
(
uintmax_t
)
ct
->
upper_bound
)
inext
=
1
;
inext
=
1
;
}
}
ASN_DEBUG
(
"Value %lu (%02x/%"
ASN_PRI_SIZE
") lb %lu ub %lu %s"
,
ASN_DEBUG
(
"Value %lu (%02x/%"
ASN_PRI_SIZE
") lb %lu ub %lu %s"
,
uval
,
st
->
buf
[
0
],
st
->
size
,
value
.
u
,
st
->
buf
[
0
],
st
->
size
,
ct
->
lower_bound
,
ct
->
upper_bound
,
ct
->
lower_bound
,
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
inext
?
"ext"
:
"fix"
);
value
=
uval
;
}
else
{
}
else
{
if
(
asn_INTEGER2imax
(
st
,
&
value
))
if
(
asn_INTEGER2imax
(
st
,
&
value
.
s
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
/* Check proper range */
/* Check proper range */
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
ct
->
flags
&
APC_SEMI_CONSTRAINED
)
{
if
(
value
<
ct
->
lower_bound
)
if
(
value
.
s
<
ct
->
lower_bound
)
inext
=
1
;
inext
=
1
;
}
else
if
(
ct
->
range_bits
>=
0
)
{
}
else
if
(
ct
->
range_bits
>=
0
)
{
if
(
value
<
ct
->
lower_bound
if
(
value
.
s
<
ct
->
lower_bound
||
value
>
ct
->
upper_bound
)
||
value
.
s
>
ct
->
upper_bound
)
inext
=
1
;
inext
=
1
;
}
}
ASN_DEBUG
(
"Value %ld (%02x/%"
ASN_PRI_SIZE
") lb %ld ub %ld %s"
,
ASN_DEBUG
(
"Value %ld (%02x/%"
ASN_PRI_SIZE
") lb %ld ub %ld %s"
,
value
,
st
->
buf
[
0
],
st
->
size
,
value
.
s
,
st
->
buf
[
0
],
st
->
size
,
ct
->
lower_bound
,
ct
->
upper_bound
,
ct
->
lower_bound
,
ct
->
upper_bound
,
inext
?
"ext"
:
"fix"
);
inext
?
"ext"
:
"fix"
);
}
}
...
@@ -193,22 +194,22 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
...
@@ -193,22 +194,22 @@ INTEGER_encode_uper(const asn_TYPE_descriptor_t *td,
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
if
(
ct
&&
ct
->
range_bits
>=
0
)
{
uintmax_t
v
;
uintmax_t
v
;
/* #11.5.6 -> #11.3 */
/* #11.5.6 -> #11.3 */
ASN_DEBUG
(
"Encoding integer %ld (%lu) with range %d bits"
,
value
,
value
-
ct
->
lower_bound
,
ct
->
range_bits
);
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(
specs
&&
specs
->
field_unsigned
)
{
if
(((
uintmax_t
)
ct
->
lower_bound
>
(
uintmax_t
)(
ct
->
upper_bound
)
if
(((
uintmax_t
)
ct
->
lower_bound
>
(
uintmax_t
)(
ct
->
upper_bound
)
||
(
(
uintmax_t
)
value
<
(
uintmax_t
)
ct
->
lower_bound
))
||
(
value
.
u
<
(
uintmax_t
)
ct
->
lower_bound
))
||
(
(
uintmax_t
)
value
>
(
uintmax_t
)
ct
->
upper_bound
))
{
||
(
value
.
u
>
(
uintmax_t
)
ct
->
upper_bound
))
{
ASN_DEBUG
(
"Value %lu to-be-encoded is outside the bounds [%lu, %lu]!"
,
ASN_DEBUG
(
"Value %lu to-be-encoded is outside the bounds [%lu, %lu]!"
,
value
,
ct
->
lower_bound
,
ct
->
upper_bound
);
value
.
u
,
ct
->
lower_bound
,
ct
->
upper_bound
);
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
}
}
v
=
(
uintmax_t
)
value
-
(
uintmax_t
)
ct
->
lower_bound
;
v
=
value
.
u
-
(
uintmax_t
)
ct
->
lower_bound
;
}
else
{
}
else
{
if
(
per_imax_range_rebase
(
value
,
ct
->
lower_bound
,
ct
->
upper_bound
,
&
v
))
{
if
(
per_imax_range_rebase
(
value
.
s
,
ct
->
lower_bound
,
ct
->
upper_bound
,
&
v
))
{
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
}
}
}
}
ASN_DEBUG
(
"Encoding integer %lu with range %d bits"
,
v
,
ct
->
range_bits
);
if
(
uper_put_constrained_whole_number_u
(
po
,
v
,
ct
->
range_bits
))
if
(
uper_put_constrained_whole_number_u
(
po
,
v
,
ct
->
range_bits
))
ASN__ENCODE_FAILED
;
ASN__ENCODE_FAILED
;
ASN__ENCODED_OK
(
er
);
ASN__ENCODED_OK
(
er
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment