Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
7cc06ef8
Commit
7cc06ef8
authored
Jun 15, 2020
by
Brian Wolfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timers: just make the buffers big enough
parent
f25ea40a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
timers.cc
src/timers.cc
+8
-5
No files found.
src/timers.cc
View file @
7cc06ef8
...
@@ -189,8 +189,9 @@ std::string LocalDateTimeString() {
...
@@ -189,8 +189,9 @@ std::string LocalDateTimeString() {
std
::
size_t
timestamp_len
;
std
::
size_t
timestamp_len
;
long
int
offset_minutes
;
long
int
offset_minutes
;
char
tz_offset_sign
=
'+'
;
char
tz_offset_sign
=
'+'
;
char
tz_offset
[
kTzOffsetLen
+
1
];
// Long enough buffers to avoid format-overflow warnings
char
storage
[
kTimestampLen
+
kTzOffsetLen
+
1
];
char
tz_offset
[
128
];
char
storage
[
128
];
#if defined(BENCHMARK_OS_WINDOWS)
#if defined(BENCHMARK_OS_WINDOWS)
std
::
tm
*
timeinfo_p
=
::
localtime
(
&
now
);
std
::
tm
*
timeinfo_p
=
::
localtime
(
&
now
);
...
@@ -214,8 +215,8 @@ std::string LocalDateTimeString() {
...
@@ -214,8 +215,8 @@ std::string LocalDateTimeString() {
}
}
tz_len
=
::
snprintf
(
tz_offset
,
sizeof
(
tz_offset
),
"%c%02li:%02li"
,
tz_len
=
::
snprintf
(
tz_offset
,
sizeof
(
tz_offset
),
"%c%02li:%02li"
,
tz_offset_sign
,
(
offset_minutes
/
100
)
,
offset_minutes
%
100
);
tz_offset_sign
,
offset_minutes
/
100
,
offset_minutes
%
100
);
CHECK
(
tz_len
==
6
);
CHECK
(
tz_len
==
kTzOffsetLen
);
((
void
)
tz_len
);
// Prevent unused variable warning in optimized build.
((
void
)
tz_len
);
// Prevent unused variable warning in optimized build.
}
else
{
}
else
{
// Unknown offset. RFC3339 specifies that unknown local offsets should be
// Unknown offset. RFC3339 specifies that unknown local offsets should be
...
@@ -233,7 +234,9 @@ std::string LocalDateTimeString() {
...
@@ -233,7 +234,9 @@ std::string LocalDateTimeString() {
timestamp_len
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%Y-%m-%dT%H:%M:%S"
,
timestamp_len
=
std
::
strftime
(
storage
,
sizeof
(
storage
),
"%Y-%m-%dT%H:%M:%S"
,
timeinfo_p
);
timeinfo_p
);
CHECK
(
timestamp_len
==
kTimestampLen
);
CHECK
(
timestamp_len
==
kTimestampLen
);
((
void
)
timestamp_len
);
// Prevent unused variable warning in optimized build.
// Prevent unused variable warning in optimized build.
((
void
)
timestamp_len
);
((
void
)
kTimestampLen
);
std
::
strncat
(
storage
,
tz_offset
,
kTzOffsetLen
+
1
);
std
::
strncat
(
storage
,
tz_offset
,
kTzOffsetLen
+
1
);
return
std
::
string
(
storage
);
return
std
::
string
(
storage
);
...
...
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