Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Achim Morschhauser
GeomagLogger
Commits
43598c63
Commit
43598c63
authored
Nov 06, 2018
by
Achim Morschhauser
Browse files
Fix uninitialized tm in data_obs
parent
e36e60d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/data_obs.cpp
View file @
43598c63
...
...
@@ -118,16 +118,19 @@ int data_obs::set_time(int year, int mon, int day, int hour, int min, int sec,
********************************************************************************/
int
data_obs
::
set_time
(
struct
timespec
*
time
)
{
struct
tm
*
tm
;
gmtime_r
(
&
time
->
tv_sec
,
tm
);
year
=
tm
->
tm_year
+
1900
;
mon
=
tm
->
tm_mon
+
1
;
day
=
tm
->
tm_mday
;
hour
=
tm
->
tm_hour
;
min
=
tm
->
tm_min
;
sec
=
tm
->
tm_sec
;
// Initialize tm
//TODO Make t a class-variable to avoid repeated allocation
struct
tm
t
=
{
0
};
// Use gmtime_r for thread-safety
gmtime_r
(
&
time
->
tv_sec
,
&
t
);
year
=
t
.
tm_year
+
1900
;
mon
=
t
.
tm_mon
+
1
;
day
=
t
.
tm_mday
;
hour
=
t
.
tm_hour
;
min
=
t
.
tm_min
;
sec
=
t
.
tm_sec
;
msec
=
(
int
)
(
time
->
tv_nsec
/
1e6
);
return
(
0
);
...
...
Write
Preview
Supports
Markdown
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