Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
efeb4479
Commit
efeb4479
authored
Mar 13, 2016
by
Francis Dupont
Browse files
[4326] Addressed coverity CID 1202661
parent
b2e7801e
Changes
1
Show whitespace changes
Inline
Side-by-side
src/lib/util/time_utilities.cc
View file @
efeb4479
...
...
@@ -136,7 +136,7 @@ namespace {
const
size_t
DATE_LEN
=
14
;
// YYYYMMDDHHmmSS
inline
void
checkRange
(
const
int
min
,
const
int
max
,
const
int
value
,
checkRange
(
const
unsigned
min
,
const
unsigned
max
,
const
unsigned
value
,
const
string
&
valname
)
{
if
((
value
>=
min
)
&&
(
value
<=
max
))
{
...
...
@@ -157,9 +157,9 @@ timeFromText64(const string& time_txt) {
}
}
int
year
,
month
,
day
,
hour
,
minute
,
second
;
unsigned
year
,
month
,
day
,
hour
,
minute
,
second
;
if
(
time_txt
.
length
()
!=
DATE_LEN
||
sscanf
(
time_txt
.
c_str
(),
"%4
d
%2
d
%2
d
%2
d
%2
d
%2
d
"
,
sscanf
(
time_txt
.
c_str
(),
"%4
u
%2
u
%2
u
%2
u
%2
u
%2
u
"
,
&
year
,
&
month
,
&
day
,
&
hour
,
&
minute
,
&
second
)
!=
6
)
{
isc_throw
(
InvalidTime
,
"Couldn't convert time value: "
<<
time_txt
);
...
...
@@ -173,16 +173,16 @@ timeFromText64(const string& time_txt) {
checkRange
(
0
,
59
,
minute
,
"minute"
);
checkRange
(
0
,
60
,
second
,
"second"
);
// 60 == leap second.
uint64_t
timeval
=
second
+
(
60
*
minute
)
+
(
3600
*
hour
)
+
((
day
-
1
)
*
86400
);
for
(
int
m
=
0
;
m
<
(
month
-
1
);
++
m
)
{
timeval
+=
days
[
m
]
*
86400
;
uint64_t
timeval
=
second
+
(
60
ULL
*
minute
)
+
(
3600
ULL
*
hour
)
+
((
day
-
1
)
*
86400
ULL
);
for
(
unsigned
m
=
0
;
m
<
(
month
-
1
);
++
m
)
{
timeval
+=
days
[
m
]
*
86400
ULL
;
}
if
(
isLeap
(
year
)
&&
month
>
2
)
{
timeval
+=
86400
;
timeval
+=
86400
ULL
;
}
for
(
int
y
=
1970
;
y
<
year
;
++
y
)
{
timeval
+=
((
isLeap
(
y
)
?
366
:
365
)
*
86400
);
for
(
unsigned
y
=
1970
;
y
<
year
;
++
y
)
{
timeval
+=
((
isLeap
(
y
)
?
366
:
365
)
*
86400
ULL
);
}
return
(
timeval
);
...
...
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