Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
162
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
atlas
athena
Merge requests
!75548
main-coverity-AthenaMonitoring
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
main-coverity-AthenaMonitoring
sroe/athena:main-coverity-AthenaMonitoring
into
main
Overview
7
Commits
1
Pipelines
1
Changes
2
Merged
Shaun Roe
requested to merge
sroe/athena:main-coverity-AthenaMonitoring
into
main
2 months ago
Overview
7
Commits
1
Pipelines
1
Changes
2
Expand
Sanitise inputs from file; also tidy headers and use fstream.
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
e40351a2
1 commit,
2 months ago
2 files
+
28
−
24
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
Control/AthenaMonitoring/src/AthMonBench.cxx
+
22
−
15
Options
@@ -3,25 +3,32 @@
*/
#include
"AthMonBench.h"
#include
<cstring>
#include
<stdio.h>
#include
<iostream>
#include
<limits>
#include
<fstream>
AthMonBench
::
TMem
AthMonBench
::
currentVMem
()
{
namespace
{
template
<
long
f
>
long
multiply
(
long
result
){
static
constexpr
long
maxval
=
std
::
numeric_limits
<
long
>::
max
()
/
f
;
if
((
result
>
maxval
)
or
(
result
<
0
))
return
-
1
;
return
result
*
f
;
}
}
AthMonBench
::
TMem
AthMonBench
::
currentVMem
(){
long
result
=
-
1
;
FILE
*
file
=
fopen
(
"/proc/self/status"
,
"r"
);
if
(
!
file
)
return
result
;
char
line
[
128
];
while
(
fgets
(
line
,
128
,
file
)
!=
NULL
){
if
(
strncmp
(
line
,
"VmSize:"
,
7
)
==
0
)
{
std
::
stringstream
s
(
&
(
line
[
7
]));
s
>>
result
;
result
*=
1024
;
//NB: ~1K uncertainty
break
;
std
::
ifstream
file
(
"/proc/self/status"
);
const
std
::
string
search
{
"VmSize:"
};
std
::
string
line
;
while
(
getline
(
file
,
line
))
{
if
(
line
.
starts_with
(
search
))
{
result
=
std
::
stol
(
line
.
substr
(
search
.
size
()));
result
=
multiply
<
1024L
>
(
result
);
}
}
fclose
(
file
);
return
result
;
}
Loading