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
12359bb6
Unverified
Commit
12359bb6
authored
Feb 13, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: convert to strequal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
ff2006ee
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
14 deletions
+15
-14
cgfsng.c
src/lxc/cgroups/cgfsng.c
+12
-12
cgroup.c
src/lxc/cgroups/cgroup.c
+2
-1
cgroup2_devices.c
src/lxc/cgroups/cgroup2_devices.c
+1
-1
No files found.
src/lxc/cgroups/cgfsng.c
View file @
12359bb6
...
@@ -86,7 +86,7 @@ static bool string_in_list(char **list, const char *entry)
...
@@ -86,7 +86,7 @@ static bool string_in_list(char **list, const char *entry)
return
false
;
return
false
;
for
(
int
i
=
0
;
list
[
i
];
i
++
)
for
(
int
i
=
0
;
list
[
i
];
i
++
)
if
(
str
cmp
(
list
[
i
],
entry
)
==
0
)
if
(
str
equal
(
list
[
i
],
entry
)
)
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -167,12 +167,12 @@ static struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *contr
...
@@ -167,12 +167,12 @@ static struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *contr
* from cgroup to cgroup2.
* from cgroup to cgroup2.
*/
*/
if
(
pure_unified_layout
(
ops
))
{
if
(
pure_unified_layout
(
ops
))
{
if
(
str
cmp
(
controller
,
"devices"
)
==
0
)
{
if
(
str
equal
(
controller
,
"devices"
)
)
{
if
(
ops
->
unified
->
bpf_device_controller
)
if
(
ops
->
unified
->
bpf_device_controller
)
return
ops
->
unified
;
return
ops
->
unified
;
break
;
break
;
}
else
if
(
str
cmp
(
controller
,
"freezer"
)
==
0
)
{
}
else
if
(
str
equal
(
controller
,
"freezer"
)
)
{
if
(
ops
->
unified
->
freezer_controller
)
if
(
ops
->
unified
->
freezer_controller
)
return
ops
->
unified
;
return
ops
->
unified
;
...
@@ -782,7 +782,7 @@ static bool controller_in_clist(char *cgline, char *c)
...
@@ -782,7 +782,7 @@ static bool controller_in_clist(char *cgline, char *c)
tmp
[
len
]
=
'\0'
;
tmp
[
len
]
=
'\0'
;
lxc_iterate_parts
(
tok
,
tmp
,
","
)
lxc_iterate_parts
(
tok
,
tmp
,
","
)
if
(
str
cmp
(
tok
,
c
)
==
0
)
if
(
str
equal
(
tok
,
c
)
)
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -2618,12 +2618,12 @@ static int device_cgroup_rule_parse(struct device_item *device, const char *key,
...
@@ -2618,12 +2618,12 @@ static int device_cgroup_rule_parse(struct device_item *device, const char *key,
int
count
,
ret
;
int
count
,
ret
;
char
temp
[
50
];
char
temp
[
50
];
if
(
str
cmp
(
"devices.allow"
,
key
)
==
0
)
if
(
str
equal
(
"devices.allow"
,
key
)
)
device
->
allow
=
1
;
device
->
allow
=
1
;
else
else
device
->
allow
=
0
;
device
->
allow
=
0
;
if
(
str
cmp
(
val
,
"a"
)
==
0
)
{
if
(
str
equal
(
val
,
"a"
)
)
{
/* global rule */
/* global rule */
device
->
type
=
'a'
;
device
->
type
=
'a'
;
device
->
major
=
-
1
;
device
->
major
=
-
1
;
...
@@ -2722,7 +2722,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
...
@@ -2722,7 +2722,7 @@ __cgfsng_ops static int cgfsng_set(struct cgroup_ops *ops,
if
(
p
)
if
(
p
)
*
p
=
'\0'
;
*
p
=
'\0'
;
if
(
pure_unified_layout
(
ops
)
&&
str
cmp
(
controller
,
"devices"
)
==
0
)
{
if
(
pure_unified_layout
(
ops
)
&&
str
equal
(
controller
,
"devices"
)
)
{
struct
device_item
device
=
{};
struct
device_item
device
=
{};
ret
=
device_cgroup_rule_parse
(
&
device
,
key
,
value
);
ret
=
device_cgroup_rule_parse
(
&
device
,
key
,
value
);
...
@@ -2862,7 +2862,7 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
...
@@ -2862,7 +2862,7 @@ static int cg_legacy_set_data(struct cgroup_ops *ops, const char *filename,
if
(
p
)
if
(
p
)
*
p
=
'\0'
;
*
p
=
'\0'
;
if
(
str
cmp
(
"devices.allow"
,
filename
)
==
0
&&
value
[
0
]
==
'/'
)
{
if
(
str
equal
(
"devices.allow"
,
filename
)
&&
value
[
0
]
==
'/'
)
{
int
ret
;
int
ret
;
ret
=
convert_devpath
(
value
,
converted_value
);
ret
=
convert_devpath
(
value
,
converted_value
);
...
@@ -2952,7 +2952,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
...
@@ -2952,7 +2952,7 @@ static int bpf_device_cgroup_prepare(struct cgroup_ops *ops,
struct
device_item
device_item
=
{};
struct
device_item
device_item
=
{};
int
ret
;
int
ret
;
if
(
str
cmp
(
"devices.allow"
,
key
)
==
0
&&
*
val
==
'/'
)
if
(
str
equal
(
"devices.allow"
,
key
)
&&
*
val
==
'/'
)
ret
=
device_cgroup_rule_parse_devpath
(
&
device_item
,
val
);
ret
=
device_cgroup_rule_parse_devpath
(
&
device_item
,
val
);
else
else
ret
=
device_cgroup_rule_parse
(
&
device_item
,
key
,
val
);
ret
=
device_cgroup_rule_parse
(
&
device_item
,
key
,
val
);
...
@@ -3190,7 +3190,7 @@ static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops,
...
@@ -3190,7 +3190,7 @@ static bool cgroup_use_wants_controllers(const struct cgroup_ops *ops,
bool
found
=
false
;
bool
found
=
false
;
for
(
char
**
cur_use
=
ops
->
cgroup_use
;
cur_use
&&
*
cur_use
;
cur_use
++
)
{
for
(
char
**
cur_use
=
ops
->
cgroup_use
;
cur_use
&&
*
cur_use
;
cur_use
++
)
{
if
(
strcmp
(
*
cur_use
,
*
cur_ctrl
)
!=
0
)
if
(
!
strequal
(
*
cur_use
,
*
cur_ctrl
)
)
continue
;
continue
;
found
=
true
;
found
=
true
;
...
@@ -3228,7 +3228,7 @@ static void cg_unified_delegate(char ***delegate)
...
@@ -3228,7 +3228,7 @@ static void cg_unified_delegate(char ***delegate)
* We always need to chown this for both cgroup and
* We always need to chown this for both cgroup and
* cgroup2.
* cgroup2.
*/
*/
if
(
str
cmp
(
token
,
"cgroup.procs"
)
==
0
)
if
(
str
equal
(
token
,
"cgroup.procs"
)
)
continue
;
continue
;
idx
=
append_null_to_list
((
void
***
)
delegate
);
idx
=
append_null_to_list
((
void
***
)
delegate
);
...
@@ -3503,7 +3503,7 @@ __cgfsng_ops static int cgfsng_data_init(struct cgroup_ops *ops)
...
@@ -3503,7 +3503,7 @@ __cgfsng_ops static int cgfsng_data_init(struct cgroup_ops *ops)
/* copy system-wide cgroup information */
/* copy system-wide cgroup information */
cgroup_pattern
=
lxc_global_config_value
(
"lxc.cgroup.pattern"
);
cgroup_pattern
=
lxc_global_config_value
(
"lxc.cgroup.pattern"
);
if
(
cgroup_pattern
&&
strcmp
(
cgroup_pattern
,
""
)
!=
0
)
if
(
cgroup_pattern
&&
!
strequal
(
cgroup_pattern
,
""
)
)
ops
->
cgroup_pattern
=
must_copy_string
(
cgroup_pattern
);
ops
->
cgroup_pattern
=
must_copy_string
(
cgroup_pattern
);
return
0
;
return
0
;
...
...
src/lxc/cgroups/cgroup.c
View file @
12359bb6
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "initutils.h"
#include "initutils.h"
#include "log.h"
#include "log.h"
#include "start.h"
#include "start.h"
#include "string_utils.h"
lxc_log_define
(
cgroup
,
lxc
);
lxc_log_define
(
cgroup
,
lxc
);
...
@@ -105,7 +106,7 @@ void prune_init_scope(char *cg)
...
@@ -105,7 +106,7 @@ void prune_init_scope(char *cg)
if
(
point
<
cg
)
if
(
point
<
cg
)
return
;
return
;
if
(
str
cmp
(
point
,
INIT_SCOPE
)
==
0
)
{
if
(
str
equal
(
point
,
INIT_SCOPE
)
)
{
if
(
point
==
cg
)
if
(
point
==
cg
)
*
(
point
+
1
)
=
'\0'
;
*
(
point
+
1
)
=
'\0'
;
else
else
...
...
src/lxc/cgroups/cgroup2_devices.c
View file @
12359bb6
...
@@ -493,7 +493,7 @@ int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device)
...
@@ -493,7 +493,7 @@ int bpf_list_add_device(struct lxc_conf *conf, struct device_item *device)
continue
;
continue
;
if
(
cur
->
minor
!=
device
->
minor
)
if
(
cur
->
minor
!=
device
->
minor
)
continue
;
continue
;
if
(
strcmp
(
cur
->
access
,
device
->
access
))
if
(
!
strequal
(
cur
->
access
,
device
->
access
))
continue
;
continue
;
/*
/*
...
...
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