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
abd9627a
Unverified
Commit
abd9627a
authored
Mar 25, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confile: use lxc_list_new() everywhere
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
dee51406
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
45 deletions
+29
-45
confile.c
src/lxc/confile.c
+29
-45
No files found.
src/lxc/confile.c
View file @
abd9627a
...
...
@@ -621,17 +621,14 @@ static int set_config_net_ipv4_address(const char *key, const char *value,
if
(
!
netdev
)
return
ret_errno
(
EINVAL
);
inetdev
=
m
alloc
(
sizeof
(
*
inetdev
));
inetdev
=
z
alloc
(
sizeof
(
*
inetdev
));
if
(
!
inetdev
)
return
ret_errno
(
ENOMEM
);
memset
(
inetdev
,
0
,
sizeof
(
*
inetdev
));
list
=
malloc
(
sizeof
(
*
list
)
);
list
=
lxc_list_new
(
);
if
(
!
list
)
return
ret_errno
(
ENOMEM
);
lxc_list_init
(
list
);
addr
=
strdup
(
value
);
if
(
!
addr
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -708,7 +705,7 @@ static int set_config_net_ipv4_gateway(const char *key, const char *value,
__do_free
struct
in_addr
*
gw
=
NULL
;
int
ret
;
gw
=
m
alloc
(
sizeof
(
*
gw
));
gw
=
z
alloc
(
sizeof
(
*
gw
));
if
(
!
gw
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -744,16 +741,14 @@ static int set_config_net_veth_ipv4_route(const char *key, const char *value,
EINVAL
,
"Invalid ipv4 route
\"
%s
\"
, can only be used with veth network"
,
value
);
inetdev
=
m
alloc
(
sizeof
(
*
inetdev
));
inetdev
=
z
alloc
(
sizeof
(
*
inetdev
));
if
(
!
inetdev
)
return
ret_errno
(
ENOMEM
);
memset
(
inetdev
,
0
,
sizeof
(
*
inetdev
));
list
=
malloc
(
sizeof
(
*
list
)
);
list
=
lxc_list_new
(
);
if
(
!
list
)
return
ret_errno
(
ENOMEM
);
lxc_list_init
(
list
);
list
->
elem
=
inetdev
;
valdup
=
strdup
(
value
);
...
...
@@ -802,17 +797,14 @@ static int set_config_net_ipv6_address(const char *key, const char *value,
if
(
!
netdev
)
return
ret_errno
(
EINVAL
);
inet6dev
=
m
alloc
(
sizeof
(
*
inet6dev
));
inet6dev
=
z
alloc
(
sizeof
(
*
inet6dev
));
if
(
!
inet6dev
)
return
ret_errno
(
ENOMEM
);
memset
(
inet6dev
,
0
,
sizeof
(
*
inet6dev
));
list
=
malloc
(
sizeof
(
*
list
)
);
list
=
lxc_list_new
(
);
if
(
!
list
)
return
ret_errno
(
ENOMEM
);
lxc_list_init
(
list
);
valdup
=
strdup
(
value
);
if
(
!
valdup
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -864,7 +856,7 @@ static int set_config_net_ipv6_gateway(const char *key, const char *value,
int
ret
;
__do_free
struct
in6_addr
*
gw
=
NULL
;
gw
=
m
alloc
(
sizeof
(
*
gw
));
gw
=
z
alloc
(
sizeof
(
*
gw
));
if
(
!
gw
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -901,17 +893,14 @@ static int set_config_net_veth_ipv6_route(const char *key, const char *value,
EINVAL
,
"Invalid ipv6 route
\"
%s
\"
, can only be used with veth network"
,
value
);
inet6dev
=
m
alloc
(
sizeof
(
*
inet6dev
));
inet6dev
=
z
alloc
(
sizeof
(
*
inet6dev
));
if
(
!
inet6dev
)
return
ret_errno
(
ENOMEM
);
memset
(
inet6dev
,
0
,
sizeof
(
*
inet6dev
));
list
=
malloc
(
sizeof
(
*
list
)
);
list
=
lxc_list_new
(
);
if
(
!
list
)
return
ret_errno
(
ENOMEM
);
lxc_list_init
(
list
);
valdup
=
strdup
(
value
);
if
(
!
valdup
)
return
-
1
;
...
...
@@ -976,7 +965,7 @@ static int add_hook(struct lxc_conf *lxc_conf, int which, __owns char *hook)
__do_free
char
*
val
=
hook
;
struct
lxc_list
*
hooklist
;
hooklist
=
malloc
(
sizeof
(
*
hooklist
)
);
hooklist
=
lxc_list_new
(
);
if
(
!
hooklist
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -1294,7 +1283,7 @@ static int set_config_group(const char *key, const char *value,
lxc_iterate_parts
(
token
,
groups
,
"
\t
"
)
{
__do_free
struct
lxc_list
*
grouplist
=
NULL
;
grouplist
=
malloc
(
sizeof
(
*
grouplist
)
);
grouplist
=
lxc_list_new
(
);
if
(
!
grouplist
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -1316,7 +1305,7 @@ static int set_config_environment(const char *key, const char *value,
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_environment
(
lxc_conf
);
list_item
=
malloc
(
sizeof
(
*
list_item
)
);
list_item
=
lxc_list_new
(
);
if
(
!
list_item
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -1430,7 +1419,7 @@ static int set_config_apparmor_raw(const char *key,
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_apparmor_raw
(
lxc_conf
);
list
=
malloc
(
sizeof
(
*
list
)
);
list
=
lxc_list_new
(
);
if
(
!
list
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -1631,14 +1620,13 @@ static int __set_config_cgroup_controller(const char *key, const char *value,
if
(
*
subkey
==
'\0'
)
return
ret_errno
(
EINVAL
);
cglist
=
malloc
(
sizeof
(
*
cglist
)
);
cglist
=
lxc_list_new
(
);
if
(
!
cglist
)
return
ret_errno
(
ENOMEM
);
cgelem
=
m
alloc
(
sizeof
(
*
cgelem
));
cgelem
=
z
alloc
(
sizeof
(
*
cgelem
));
if
(
!
cgelem
)
return
ret_errno
(
ENOMEM
);
memset
(
cgelem
,
0
,
sizeof
(
*
cgelem
));
cgelem
->
subsystem
=
strdup
(
subkey
);
if
(
!
cgelem
->
subsystem
)
...
...
@@ -1802,14 +1790,13 @@ static int set_config_prlimit(const char *key, const char *value,
}
/* allocate list element */
limlist
=
malloc
(
sizeof
(
*
limlist
)
);
limlist
=
lxc_list_new
(
);
if
(
!
limlist
)
return
ret_errno
(
ENOMEM
);
limelem
=
m
alloc
(
sizeof
(
*
limelem
));
limelem
=
z
alloc
(
sizeof
(
*
limelem
));
if
(
!
limelem
)
return
ret_errno
(
ENOMEM
);
memset
(
limelem
,
0
,
sizeof
(
*
limelem
));
limelem
->
resource
=
strdup
(
key
);
if
(
!
limelem
->
resource
)
...
...
@@ -1858,10 +1845,9 @@ static int set_config_sysctl(const char *key, const char *value,
}
/* allocate list element */
sysctl_list
=
zalloc
(
sizeof
(
*
sysctl_list
)
);
sysctl_list
=
lxc_list_new
(
);
if
(
!
sysctl_list
)
return
ret_errno
(
ENOMEM
);
lxc_list_init
(
sysctl_list
);
sysctl_elem
=
zalloc
(
sizeof
(
*
sysctl_elem
));
if
(
!
sysctl_elem
)
...
...
@@ -1898,14 +1884,13 @@ static int set_config_proc(const char *key, const char *value,
if
(
*
subkey
==
'\0'
)
return
ret_errno
(
EINVAL
);
proclist
=
malloc
(
sizeof
(
*
proclist
)
);
proclist
=
lxc_list_new
(
);
if
(
!
proclist
)
return
ret_errno
(
ENOMEM
);
procelem
=
m
alloc
(
sizeof
(
*
procelem
));
procelem
=
z
alloc
(
sizeof
(
*
procelem
));
if
(
!
procelem
)
return
ret_errno
(
ENOMEM
);
memset
(
procelem
,
0
,
sizeof
(
*
procelem
));
procelem
->
filename
=
strdup
(
subkey
);
if
(
!
procelem
->
filename
)
...
...
@@ -1933,14 +1918,13 @@ static int set_config_idmaps(const char *key, const char *value,
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_idmaps
(
lxc_conf
);
idmaplist
=
malloc
(
sizeof
(
*
idmaplist
)
);
idmaplist
=
lxc_list_new
(
);
if
(
!
idmaplist
)
return
ret_errno
(
ENOMEM
);
idmap
=
m
alloc
(
sizeof
(
*
idmap
));
idmap
=
z
alloc
(
sizeof
(
*
idmap
));
if
(
!
idmap
)
return
ret_errno
(
ENOMEM
);
memset
(
idmap
,
0
,
sizeof
(
*
idmap
));
ret
=
parse_idmaps
(
value
,
&
type
,
&
nsid
,
&
hostid
,
&
range
);
if
(
ret
<
0
)
...
...
@@ -2096,7 +2080,7 @@ static int set_config_mount(const char *key, const char *value,
if
(
lxc_config_value_empty
(
value
))
return
lxc_clear_mount_entries
(
lxc_conf
);
mntlist
=
malloc
(
sizeof
(
*
mntlist
)
);
mntlist
=
lxc_list_new
(
);
if
(
!
mntlist
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -2135,7 +2119,7 @@ static int set_config_cap_keep(const char *key, const char *value,
if
(
strequal
(
token
,
"none"
))
lxc_clear_config_keepcaps
(
lxc_conf
);
keeplist
=
malloc
(
sizeof
(
*
keeplist
)
);
keeplist
=
lxc_list_new
(
);
if
(
!
keeplist
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -2167,7 +2151,7 @@ static int set_config_cap_drop(const char *key, const char *value,
* split these caps in a single element for the list.
*/
lxc_iterate_parts
(
token
,
dropcaps
,
"
\t
"
)
{
droplist
=
malloc
(
sizeof
(
*
droplist
)
);
droplist
=
lxc_list_new
(
);
if
(
!
droplist
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -2507,7 +2491,7 @@ static int set_config_uts_name(const char *key, const char *value,
return
0
;
}
utsname
=
m
alloc
(
sizeof
(
*
utsname
));
utsname
=
z
alloc
(
sizeof
(
*
utsname
));
if
(
!
utsname
)
return
ret_errno
(
ENOMEM
);
...
...
@@ -2713,7 +2697,7 @@ static struct new_config_item *parse_new_conf_line(char *buffer)
}
}
new
=
m
alloc
(
sizeof
(
struct
new_config_item
));
new
=
z
alloc
(
sizeof
(
struct
new_config_item
));
if
(
!
new
)
return
NULL
;
...
...
@@ -2748,7 +2732,7 @@ int lxc_config_define_add(struct lxc_list *defines, char *arg)
{
__do_free
struct
lxc_list
*
dent
=
NULL
;
dent
=
malloc
(
sizeof
(
struct
lxc_list
)
);
dent
=
lxc_list_new
(
);
if
(
!
dent
)
return
ret_errno
(
ENOMEM
);
...
...
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