Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
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
lxc
Commits
d0943d3f
Unverified
Commit
d0943d3f
authored
Jun 15, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverity: #1425804
Unchecked return value Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
a5a6cc87
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
lxc_info.c
src/lxc/tools/lxc_info.c
+16
-10
No files found.
src/lxc/tools/lxc_info.c
View file @
d0943d3f
...
...
@@ -112,19 +112,19 @@ static void str_chomp(char *buf)
static
void
size_humanize
(
unsigned
long
long
val
,
char
*
buf
,
size_t
bufsz
)
{
if
(
val
>
1
<<
30
)
{
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
(
unsigned
int
)(
val
>>
30
),
(
unsigned
int
)(
val
&
((
1
<<
30
)
-
1
))
/
10737419
);
(
void
)
snprintf
(
buf
,
bufsz
,
"%u.%2.2u GiB"
,
(
unsigned
int
)(
val
>>
30
),
(
unsigned
int
)(
val
&
((
1
<<
30
)
-
1
))
/
10737419
);
}
else
if
(
val
>
1
<<
20
)
{
unsigned
int
x
=
val
+
5243
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
x
>>
20
,
((
x
&
((
1
<<
20
)
-
1
))
*
100
)
>>
20
);
(
void
)
snprintf
(
buf
,
bufsz
,
"%u.%2.2u MiB"
,
x
>>
20
,
((
x
&
((
1
<<
20
)
-
1
))
*
100
)
>>
20
);
}
else
if
(
val
>
1
<<
10
)
{
unsigned
int
x
=
val
+
5
;
/* for rounding */
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
x
>>
10
,
((
x
&
((
1
<<
10
)
-
1
))
*
100
)
>>
10
);
(
void
)
snprintf
(
buf
,
bufsz
,
"%u.%2.2u KiB"
,
x
>>
10
,
((
x
&
((
1
<<
10
)
-
1
))
*
100
)
>>
10
);
}
else
{
snprintf
(
buf
,
bufsz
,
"%u bytes"
,
(
unsigned
int
)
val
);
(
void
)
snprintf
(
buf
,
bufsz
,
"%u bytes"
,
(
unsigned
int
)
val
);
}
}
...
...
@@ -172,7 +172,10 @@ static void print_net_stats(struct lxc_container *c)
/* XXX: tx and rx are reversed from the host vs container
* perspective, print them from the container perspective
*/
snprintf
(
path
,
sizeof
(
path
),
"/sys/class/net/%s/statistics/rx_bytes"
,
ifname
);
rc
=
snprintf
(
path
,
sizeof
(
path
),
"/sys/class/net/%s/statistics/rx_bytes"
,
ifname
);
if
(
rc
<
0
||
(
size_t
)
rc
>=
sizeof
(
path
))
return
;
rc
=
lxc_read_from_file
(
path
,
buf
,
sizeof
(
buf
));
if
(
rc
>
0
)
{
str_chomp
(
buf
);
...
...
@@ -181,7 +184,10 @@ static void print_net_stats(struct lxc_container *c)
fflush
(
stdout
);
}
snprintf
(
path
,
sizeof
(
path
),
"/sys/class/net/%s/statistics/tx_bytes"
,
ifname
);
rc
=
snprintf
(
path
,
sizeof
(
path
),
"/sys/class/net/%s/statistics/tx_bytes"
,
ifname
);
if
(
rc
<
0
||
(
size_t
)
rc
>=
sizeof
(
path
))
return
;
rc
=
lxc_read_from_file
(
path
,
buf
,
sizeof
(
buf
));
if
(
rc
>
0
)
{
str_chomp
(
buf
);
...
...
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