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
9c57f33a
Commit
9c57f33a
authored
Sep 17, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove undefined behavior sanitizer warnings
parent
642b92f3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
13 deletions
+10
-13
skeletons/REAL.c
skeletons/REAL.c
+4
-4
tests/tests-skeletons/check-REAL.c
tests/tests-skeletons/check-REAL.c
+6
-9
No files found.
skeletons/REAL.c
View file @
9c57f33a
...
@@ -577,8 +577,8 @@ asn_REAL2double(const REAL_t *st, double *dbl_value) {
...
@@ -577,8 +577,8 @@ asn_REAL2double(const REAL_t *st, double *dbl_value) {
double
m
;
double
m
;
int
expval
;
/* exponent value */
int
expval
;
/* exponent value */
unsigned
int
elen
;
/* exponent value length, in octets */
unsigned
int
elen
;
/* exponent value length, in octets */
unsigned
int
scaleF
;
int
scaleF
;
unsigned
int
baseF
;
int
baseF
;
uint8_t
*
ptr
;
uint8_t
*
ptr
;
uint8_t
*
end
;
uint8_t
*
end
;
int
sign
;
int
sign
;
...
@@ -754,8 +754,8 @@ asn_double2REAL(REAL_t *st, double dbl_value) {
...
@@ -754,8 +754,8 @@ asn_double2REAL(REAL_t *st, double dbl_value) {
/* This loop ensures DER conformance by forcing mantissa odd: 11.3.1 */
/* This loop ensures DER conformance by forcing mantissa odd: 11.3.1 */
mval
=
*
mstop
;
mval
=
*
mstop
;
if
(
mval
&&
!
(
mval
&
1
))
{
if
(
mval
&&
!
(
mval
&
1
))
{
unsigned
int
shift_count
=
1
;
int
shift_count
=
1
;
unsigned
int
ishift
;
int
ishift
;
uint8_t
*
mptr
;
uint8_t
*
mptr
;
/*
/*
...
...
tests/tests-skeletons/check-REAL.c
View file @
9c57f33a
...
@@ -345,8 +345,6 @@ check_ber_857_encoding(int base, int sign, int scaling_factor, int exponent, int
...
@@ -345,8 +345,6 @@ check_ber_857_encoding(int base, int sign, int scaling_factor, int exponent, int
static
void
static
void
check_ber_encoding
()
{
check_ber_encoding
()
{
static
const
double
zero
=
0
.
0
;
#define CHECK_BER_STRICT(v, nocan, can, inbuf, outbuf) \
#define CHECK_BER_STRICT(v, nocan, can, inbuf, outbuf) \
check_ber_buffer_twoway(v, nocan, can, inbuf, sizeof(inbuf), \
check_ber_buffer_twoway(v, nocan, can, inbuf, sizeof(inbuf), \
outbuf, sizeof(outbuf), __LINE__)
outbuf, sizeof(outbuf), __LINE__)
...
@@ -382,9 +380,9 @@ check_ber_encoding() {
...
@@ -382,9 +380,9 @@ check_ber_encoding() {
{
uint8_t
b_pinf
[]
=
{
0x40
};
{
uint8_t
b_pinf
[]
=
{
0x40
};
uint8_t
b_minf
[]
=
{
0x41
};
uint8_t
b_minf
[]
=
{
0x41
};
uint8_t
b_nan
[]
=
{
0x42
};
uint8_t
b_nan
[]
=
{
0x42
};
CHECK_BER_STRICT
(
1
.
0
/
zero
,
"<PLUS-INFINITY/>"
,
"<PLUS-INFINITY/>"
,
b_pinf
,
b_pinf
);
CHECK_BER_STRICT
(
INFINITY
,
"<PLUS-INFINITY/>"
,
"<PLUS-INFINITY/>"
,
b_pinf
,
b_pinf
);
CHECK_BER_STRICT
(
-
1
.
0
/
zero
,
"<MINUS-INFINITY/>"
,
"<MINUS-INFINITY/>"
,
b_minf
,
b_minf
);
CHECK_BER_STRICT
(
-
INFINITY
,
"<MINUS-INFINITY/>"
,
"<MINUS-INFINITY/>"
,
b_minf
,
b_minf
);
CHECK_BER_STRICT
(
zero
/
zero
,
"<NOT-A-NUMBER/>"
,
"<NOT-A-NUMBER/>"
,
b_nan
,
b_nan
);
}
CHECK_BER_STRICT
(
NAN
,
"<NOT-A-NUMBER/>"
,
"<NOT-A-NUMBER/>"
,
b_nan
,
b_nan
);
}
/* 8.5.6 b) => 8.5.8 Decimal encoding is used; NR1 form */
/* 8.5.6 b) => 8.5.8 Decimal encoding is used; NR1 form */
{
uint8_t
b_0_nr1
[]
=
{
0x01
,
'0'
};
{
uint8_t
b_0_nr1
[]
=
{
0x01
,
'0'
};
...
@@ -618,16 +616,15 @@ check_ber_encoding() {
...
@@ -618,16 +616,15 @@ check_ber_encoding() {
int
int
main
()
{
main
()
{
REAL_t
rn
;
REAL_t
rn
;
static
const
double
zero
=
0
.
0
;
memset
(
&
rn
,
0
,
sizeof
(
rn
));
memset
(
&
rn
,
0
,
sizeof
(
rn
));
check_ber_encoding
();
check_ber_encoding
();
check
(
&
rn
,
0
.
0
,
"0"
,
"0"
);
check
(
&
rn
,
0
.
0
,
"0"
,
"0"
);
check
(
&
rn
,
-
0
.
0
,
"-0"
,
"-0"
);
/* minus-zero */
check
(
&
rn
,
-
0
.
0
,
"-0"
,
"-0"
);
/* minus-zero */
check
(
&
rn
,
zero
/
zero
,
"<NOT-A-NUMBER/>"
,
"<NOT-A-NUMBER/>"
);
check
(
&
rn
,
NAN
,
"<NOT-A-NUMBER/>"
,
"<NOT-A-NUMBER/>"
);
check
(
&
rn
,
1
.
0
/
zero
,
"<PLUS-INFINITY/>"
,
"<PLUS-INFINITY/>"
);
check
(
&
rn
,
INFINITY
,
"<PLUS-INFINITY/>"
,
"<PLUS-INFINITY/>"
);
check
(
&
rn
,
-
1
.
0
/
zero
,
"<MINUS-INFINITY/>"
,
"<MINUS-INFINITY/>"
);
check
(
&
rn
,
-
INFINITY
,
"<MINUS-INFINITY/>"
,
"<MINUS-INFINITY/>"
);
check
(
&
rn
,
1
.
0
,
"1.0"
,
"1.0E0"
);
check
(
&
rn
,
1
.
0
,
"1.0"
,
"1.0E0"
);
check
(
&
rn
,
-
1
.
0
,
"-1.0"
,
"-1.0E0"
);
check
(
&
rn
,
-
1
.
0
,
"-1.0"
,
"-1.0E0"
);
check
(
&
rn
,
0
.
1
,
"0.1"
,
"1.0E-1"
);
check
(
&
rn
,
0
.
1
,
"0.1"
,
"1.0E-1"
);
...
...
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