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
6b4e204c
Unverified
Commit
6b4e204c
authored
Feb 05, 2019
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loop: remove stack allocations
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
2530ba95
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
loop.c
src/lxc/storage/loop.c
+5
-4
No files found.
src/lxc/storage/loop.c
View file @
6b4e204c
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
#include "config.h"
#include "config.h"
#include "log.h"
#include "log.h"
#include "loop.h"
#include "loop.h"
#include "memory_utils.h"
#include "storage.h"
#include "storage.h"
#include "storage_utils.h"
#include "storage_utils.h"
#include "utils.h"
#include "utils.h"
...
@@ -56,9 +57,9 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -56,9 +57,9 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
const
char
*
lxcpath
,
int
snap
,
uint64_t
newsize
,
struct
lxc_conf
*
conf
)
struct
lxc_conf
*
conf
)
{
{
__do_free
char
*
srcdev
=
NULL
;
uint64_t
size
=
newsize
;
uint64_t
size
=
newsize
;
int
len
,
ret
;
int
len
,
ret
;
char
*
srcdev
;
char
fstype
[
100
]
=
"ext4"
;
char
fstype
[
100
]
=
"ext4"
;
if
(
snap
)
{
if
(
snap
)
{
...
@@ -70,7 +71,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -70,7 +71,7 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
return
-
1
;
return
-
1
;
len
=
strlen
(
lxcpath
)
+
strlen
(
cname
)
+
strlen
(
"rootdev"
)
+
3
;
len
=
strlen
(
lxcpath
)
+
strlen
(
cname
)
+
strlen
(
"rootdev"
)
+
3
;
srcdev
=
alloca
(
len
);
srcdev
=
must_realloc
(
NULL
,
len
);
ret
=
snprintf
(
srcdev
,
len
,
"%s/%s/rootdev"
,
lxcpath
,
cname
);
ret
=
snprintf
(
srcdev
,
len
,
"%s/%s/rootdev"
,
lxcpath
,
cname
);
if
(
ret
<
0
||
ret
>=
len
)
{
if
(
ret
<
0
||
ret
>=
len
)
{
ERROR
(
"Failed to create string"
);
ERROR
(
"Failed to create string"
);
...
@@ -136,10 +137,10 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
...
@@ -136,10 +137,10 @@ int loop_clonepaths(struct lxc_storage *orig, struct lxc_storage *new,
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
int
loop_create
(
struct
lxc_storage
*
bdev
,
const
char
*
dest
,
const
char
*
n
,
struct
bdev_specs
*
specs
)
struct
bdev_specs
*
specs
)
{
{
__do_free
char
*
srcdev
;
const
char
*
fstype
;
const
char
*
fstype
;
uint64_t
sz
;
uint64_t
sz
;
int
ret
,
len
;
int
ret
,
len
;
char
*
srcdev
;
if
(
!
specs
)
if
(
!
specs
)
return
-
1
;
return
-
1
;
...
@@ -148,7 +149,7 @@ int loop_create(struct lxc_storage *bdev, const char *dest, const char *n,
...
@@ -148,7 +149,7 @@ int loop_create(struct lxc_storage *bdev, const char *dest, const char *n,
* be <lxcpath>/<lxcname>/rootdev, and <src> will be "loop:<srcdev>".
* be <lxcpath>/<lxcname>/rootdev, and <src> will be "loop:<srcdev>".
*/
*/
len
=
strlen
(
dest
)
+
2
;
len
=
strlen
(
dest
)
+
2
;
srcdev
=
alloca
(
len
);
srcdev
=
must_realloc
(
NULL
,
len
);
ret
=
snprintf
(
srcdev
,
len
,
"%s"
,
dest
);
ret
=
snprintf
(
srcdev
,
len
,
"%s"
,
dest
);
if
(
ret
<
0
||
ret
>=
len
)
{
if
(
ret
<
0
||
ret
>=
len
)
{
...
...
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