Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8997116e
authored
Feb 18, 2016
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base_c: fixed uninitialized variables in failure cases
parent
5eec1ace
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
base_c/src/duration.c
+18
-0
base_c/src/thread.c
+4
-1
No files found.
base_c/src/duration.c
View file @
8997116e
...
...
@@ -49,10 +49,14 @@ int embb_duration_set_nanoseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
if
(
nanoseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
nanoseconds
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
}
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000000000
+
max
->
nanoseconds
<
nanoseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
}
}
...
...
@@ -66,10 +70,14 @@ int embb_duration_set_microseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
if
(
microseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
microseconds
*
1000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
}
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000000
+
max
->
nanoseconds
/
1000
<
microseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
}
}
...
...
@@ -83,10 +91,14 @@ int embb_duration_set_milliseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
if
(
milliseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
milliseconds
*
1000000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
}
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000
+
max
->
nanoseconds
/
1000000
<
milliseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
}
}
...
...
@@ -100,10 +112,14 @@ int embb_duration_set_seconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
if
(
seconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
seconds
*
1000000000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
}
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
+
max
->
nanoseconds
/
1000000000
<
seconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
}
}
...
...
@@ -117,6 +133,8 @@ int embb_duration_add(embb_duration_t* lhs, const embb_duration_t* rhs) {
assert
(
rhs
!=
NULL
);
int
carry
=
(
int
)((
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
/
1000000000
);
if
(
lhs
->
seconds
+
rhs
->
seconds
+
carry
>
EMBB_DURATION_MAX_SECONDS
)
{
lhs
->
seconds
=
0
;
lhs
->
nanoseconds
=
0
;
return
EMBB_OVERFLOW
;
}
lhs
->
nanoseconds
=
(
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
%
1000000000
;
...
...
base_c/src/thread.c
View file @
8997116e
...
...
@@ -83,7 +83,10 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
assert
(
thread
!=
NULL
);
thread
->
embb_internal_arg
=
(
embb_internal_thread_arg_t
*
)
embb_alloc
(
sizeof
(
embb_internal_thread_arg_t
));
if
(
thread
->
embb_internal_arg
==
NULL
)
return
EMBB_NOMEM
;
if
(
thread
->
embb_internal_arg
==
NULL
)
{
thread
->
embb_internal_handle
=
NULL
;
return
EMBB_NOMEM
;
}
thread
->
embb_internal_arg
->
func
=
func
;
thread
->
embb_internal_arg
->
arg
=
arg
;
...
...
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