Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
29cd5e1f
Commit
29cd5e1f
authored
13 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
bug 1362: sprintf -> snprintf
parent
219863a5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCS/Common/src/Stopwatch.cc
+13
-11
13 additions, 11 deletions
LCS/Common/src/Stopwatch.cc
with
13 additions
and
11 deletions
LCS/Common/src/Stopwatch.cc
+
13
−
11
View file @
29cd5e1f
...
@@ -61,22 +61,24 @@ namespace LOFAR
...
@@ -61,22 +61,24 @@ namespace LOFAR
double
ut
=
user
(),
st
=
sys
(),
rt
=
real
();
double
ut
=
user
(),
st
=
sys
(),
rt
=
real
();
if
(
opts
&
USER
)
if
(
opts
&
USER
)
{
{
sprintf
(
str
,
format
,
ut
);
out1
+=
str
;
snprintf
(
str
,
sizeof
str
,
format
,
ut
);
out1
+=
str
;
if
(
nops
)
if
(
nops
)
{
{
sprintf
(
str
,
"%12lld"
,(
long
long
)(
nops
/
(
ut
+
st
)
+
0.5
));
out2
+=
str
;
}
snprintf
(
str
,
sizeof
str
,
"%12lld"
,(
long
long
)(
nops
/
(
ut
+
st
)
+
0.5
));
out2
+=
str
;
}
}
}
if
(
opts
&
SYSTEM
)
if
(
opts
&
SYSTEM
)
{
{
sprintf
(
str
,
format
,
st
);
out1
+=
str
;
s
n
printf
(
str
,
sizeof
str
,
format
,
st
);
out1
+=
str
;
}
}
if
(
opts
&
REAL
)
if
(
opts
&
REAL
)
{
{
sprintf
(
str
,
format
,
rt
);
out1
+=
str
;
snprintf
(
str
,
sizeof
str
,
format
,
rt
);
out1
+=
str
;
if
(
nops
)
if
(
nops
)
{
{
sprintf
(
str
,
"%12lld"
,(
long
long
)(
nops
/
rt
+
0.5
));
out2
+=
str
;
}
snprintf
(
str
,
sizeof
str
,
"%12lld"
,(
long
long
)(
nops
/
rt
+
0.5
));
out2
+=
str
;
}
}
}
if
(
nops
)
if
(
nops
)
{
sprintf
(
str
,
"%12lld"
,
nops
);
out2
+=
str
;
}
{
s
n
printf
(
str
,
sizeof
str
,
"%12lld"
,
nops
);
out2
+=
str
;
}
return
out1
+
out2
;
return
out1
+
out2
;
}
}
...
@@ -84,7 +86,7 @@ namespace LOFAR
...
@@ -84,7 +86,7 @@ namespace LOFAR
string
Stopwatch
::
dump
(
const
string
&
name
,
long
long
nops
,
bool
do_reset
,
int
opts
)
string
Stopwatch
::
dump
(
const
string
&
name
,
long
long
nops
,
bool
do_reset
,
int
opts
)
{
{
char
*
str
=
new
char
[
namewidth
+
32
];
char
*
str
=
new
char
[
namewidth
+
32
];
sprintf
(
str
,
"%-*.*s:"
,
namewidth
,
namewidth
,
name
.
c_str
());
s
n
printf
(
str
,
namewidth
+
32
,
"%-*.*s:"
,
namewidth
,
namewidth
,
name
.
c_str
());
string
sstr
(
str
);
string
sstr
(
str
);
delete
[]
str
;
delete
[]
str
;
return
sstr
+
sdelta
(
nops
,
do_reset
,
opts
);
return
sstr
+
sdelta
(
nops
,
do_reset
,
opts
);
...
@@ -94,8 +96,8 @@ namespace LOFAR
...
@@ -94,8 +96,8 @@ namespace LOFAR
string
Stopwatch
::
header
(
long
long
nops
)
string
Stopwatch
::
header
(
long
long
nops
)
{
{
static
char
hdr
[
2
][
80
];
static
char
hdr
[
2
][
80
];
sprintf
(
hdr
[
0
],
"%10s%10s%10s"
,
"user"
,
"sys"
,
"real"
);
s
n
printf
(
hdr
[
0
],
sizeof
hdr
[
0
],
"%10s%10s%10s"
,
"user"
,
"sys"
,
"real"
);
sprintf
(
hdr
[
1
],
"%10s%10s%10s%12s%12s%12s"
,
"t/user"
,
"t/sys"
,
"t/real"
,
"p/cpusec"
,
"p/sec"
,
"count"
);
s
n
printf
(
hdr
[
1
],
sizeof
hdr
[
1
],
"%10s%10s%10s%12s%12s%12s"
,
"t/user"
,
"t/sys"
,
"t/real"
,
"p/cpusec"
,
"p/sec"
,
"count"
);
if
(
nops
)
if
(
nops
)
return
hdr
[
1
];
return
hdr
[
1
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment