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
9 years ago
by
Marcus Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base_c: fixed uninitialized variables in failure cases
parent
5eec1ace
Hide 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,
...
@@ -49,10 +49,14 @@ int embb_duration_set_nanoseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
assert
(
duration
!=
NULL
);
if
(
nanoseconds
>
0
)
{
if
(
nanoseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
nanoseconds
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
nanoseconds
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
return
EMBB_UNDERFLOW
;
}
}
const
embb_duration_t
*
max
=
embb_duration_max
();
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000000000
+
max
->
nanoseconds
<
nanoseconds
)
{
if
(
max
->
seconds
*
1000000000
+
max
->
nanoseconds
<
nanoseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
return
EMBB_OVERFLOW
;
}
}
}
}
...
@@ -66,10 +70,14 @@ int embb_duration_set_microseconds(embb_duration_t* duration,
...
@@ -66,10 +70,14 @@ int embb_duration_set_microseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
assert
(
duration
!=
NULL
);
if
(
microseconds
>
0
)
{
if
(
microseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
microseconds
*
1000
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
microseconds
*
1000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
return
EMBB_UNDERFLOW
;
}
}
const
embb_duration_t
*
max
=
embb_duration_max
();
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000000
+
max
->
nanoseconds
/
1000
<
microseconds
)
{
if
(
max
->
seconds
*
1000000
+
max
->
nanoseconds
/
1000
<
microseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
return
EMBB_OVERFLOW
;
}
}
}
}
...
@@ -83,10 +91,14 @@ int embb_duration_set_milliseconds(embb_duration_t* duration,
...
@@ -83,10 +91,14 @@ int embb_duration_set_milliseconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
assert
(
duration
!=
NULL
);
if
(
milliseconds
>
0
)
{
if
(
milliseconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
milliseconds
*
1000000
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
milliseconds
*
1000000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
return
EMBB_UNDERFLOW
;
}
}
const
embb_duration_t
*
max
=
embb_duration_max
();
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
*
1000
+
max
->
nanoseconds
/
1000000
<
milliseconds
)
{
if
(
max
->
seconds
*
1000
+
max
->
nanoseconds
/
1000000
<
milliseconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
return
EMBB_OVERFLOW
;
}
}
}
}
...
@@ -100,10 +112,14 @@ int embb_duration_set_seconds(embb_duration_t* duration,
...
@@ -100,10 +112,14 @@ int embb_duration_set_seconds(embb_duration_t* duration,
assert
(
duration
!=
NULL
);
assert
(
duration
!=
NULL
);
if
(
seconds
>
0
)
{
if
(
seconds
>
0
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
seconds
*
1000000000
)
{
if
(
embb_duration_min
()
->
nanoseconds
>
seconds
*
1000000000
)
{
duration
->
seconds
=
0
;
duration
->
nanoseconds
=
0
;
return
EMBB_UNDERFLOW
;
return
EMBB_UNDERFLOW
;
}
}
const
embb_duration_t
*
max
=
embb_duration_max
();
const
embb_duration_t
*
max
=
embb_duration_max
();
if
(
max
->
seconds
+
max
->
nanoseconds
/
1000000000
<
seconds
)
{
if
(
max
->
seconds
+
max
->
nanoseconds
/
1000000000
<
seconds
)
{
duration
->
seconds
=
max
->
seconds
;
duration
->
nanoseconds
=
max
->
nanoseconds
;
return
EMBB_OVERFLOW
;
return
EMBB_OVERFLOW
;
}
}
}
}
...
@@ -117,6 +133,8 @@ int embb_duration_add(embb_duration_t* lhs, const embb_duration_t* rhs) {
...
@@ -117,6 +133,8 @@ int embb_duration_add(embb_duration_t* lhs, const embb_duration_t* rhs) {
assert
(
rhs
!=
NULL
);
assert
(
rhs
!=
NULL
);
int
carry
=
(
int
)((
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
/
1000000000
);
int
carry
=
(
int
)((
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
/
1000000000
);
if
(
lhs
->
seconds
+
rhs
->
seconds
+
carry
>
EMBB_DURATION_MAX_SECONDS
)
{
if
(
lhs
->
seconds
+
rhs
->
seconds
+
carry
>
EMBB_DURATION_MAX_SECONDS
)
{
lhs
->
seconds
=
0
;
lhs
->
nanoseconds
=
0
;
return
EMBB_OVERFLOW
;
return
EMBB_OVERFLOW
;
}
}
lhs
->
nanoseconds
=
(
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
%
1000000000
;
lhs
->
nanoseconds
=
(
lhs
->
nanoseconds
+
rhs
->
nanoseconds
)
%
1000000000
;
...
...
This diff is collapsed.
Click to expand it.
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,
...
@@ -83,7 +83,10 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set,
assert
(
thread
!=
NULL
);
assert
(
thread
!=
NULL
);
thread
->
embb_internal_arg
=
(
embb_internal_thread_arg_t
*
)
thread
->
embb_internal_arg
=
(
embb_internal_thread_arg_t
*
)
embb_alloc
(
sizeof
(
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
->
func
=
func
;
thread
->
embb_internal_arg
->
arg
=
arg
;
thread
->
embb_internal_arg
->
arg
=
arg
;
...
...
This diff is collapsed.
Click to expand it.
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