Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
978019d3
Commit
978019d3
authored
Sep 08, 2011
by
Hisham Muhammad
Browse files
sanity checks
parent
f7fe4b47
Changes
2
Hide whitespace changes
Inline
Side-by-side
LoadAverageMeter.c
View file @
978019d3
...
@@ -20,12 +20,15 @@ int LoadMeter_attributes[] = { LOAD };
...
@@ -20,12 +20,15 @@ int LoadMeter_attributes[] = { LOAD };
static
inline
void
LoadAverageMeter_scan
(
double
*
one
,
double
*
five
,
double
*
fifteen
)
{
static
inline
void
LoadAverageMeter_scan
(
double
*
one
,
double
*
five
,
double
*
fifteen
)
{
int
activeProcs
,
totalProcs
,
lastProc
;
int
activeProcs
,
totalProcs
,
lastProc
;
*
one
=
0
;
*
five
=
0
;
*
fifteen
=
0
;
FILE
*
fd
=
fopen
(
PROCDIR
"/loadavg"
,
"r"
);
FILE
*
fd
=
fopen
(
PROCDIR
"/loadavg"
,
"r"
);
int
total
=
fscanf
(
fd
,
"%lf %lf %lf %d/%d %d"
,
one
,
five
,
fifteen
,
if
(
fd
)
{
&
activeProcs
,
&
totalProcs
,
&
lastProc
);
int
total
=
fscanf
(
fd
,
"%lf %lf %lf %d/%d %d"
,
one
,
five
,
fifteen
,
(
void
)
total
;
&
activeProcs
,
&
totalProcs
,
&
lastProc
);
assert
(
total
==
6
);
(
void
)
total
;
fclose
(
fd
);
assert
(
total
==
6
);
fclose
(
fd
);
}
}
}
static
void
LoadAverageMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
LoadAverageMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
...
...
UptimeMeter.c
View file @
978019d3
...
@@ -21,8 +21,10 @@ int UptimeMeter_attributes[] = {
...
@@ -21,8 +21,10 @@ int UptimeMeter_attributes[] = {
static
void
UptimeMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
static
void
UptimeMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
double
uptime
=
0
;
double
uptime
=
0
;
FILE
*
fd
=
fopen
(
PROCDIR
"/uptime"
,
"r"
);
FILE
*
fd
=
fopen
(
PROCDIR
"/uptime"
,
"r"
);
fscanf
(
fd
,
"%lf"
,
&
uptime
);
if
(
fd
)
{
fclose
(
fd
);
fscanf
(
fd
,
"%lf"
,
&
uptime
);
fclose
(
fd
);
}
int
totalseconds
=
(
int
)
ceil
(
uptime
);
int
totalseconds
=
(
int
)
ceil
(
uptime
);
int
seconds
=
totalseconds
%
60
;
int
seconds
=
totalseconds
%
60
;
int
minutes
=
(
totalseconds
/
60
)
%
60
;
int
minutes
=
(
totalseconds
/
60
)
%
60
;
...
...
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