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
928ada18
Unverified
Commit
928ada18
authored
Feb 13, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string_utils: convert to strequal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
d2cfd2ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
string_utils.c
src/lxc/string_utils.c
+6
-6
No files found.
src/lxc/string_utils.c
View file @
928ada18
...
@@ -156,7 +156,7 @@ char *lxc_string_replace(const char *needle, const char *replacement,
...
@@ -156,7 +156,7 @@ char *lxc_string_replace(const char *needle, const char *replacement,
bool
lxc_string_in_array
(
const
char
*
needle
,
const
char
**
haystack
)
bool
lxc_string_in_array
(
const
char
*
needle
,
const
char
**
haystack
)
{
{
for
(;
haystack
&&
*
haystack
;
haystack
++
)
for
(;
haystack
&&
*
haystack
;
haystack
++
)
if
(
!
strcmp
(
needle
,
*
haystack
))
if
(
strequal
(
needle
,
*
haystack
))
return
true
;
return
true
;
return
false
;
return
false
;
...
@@ -208,14 +208,14 @@ char **lxc_normalize_path(const char *path)
...
@@ -208,14 +208,14 @@ char **lxc_normalize_path(const char *path)
/* resolve '.' and '..' */
/* resolve '.' and '..' */
for
(
pos
=
0
;
pos
<
components_len
;)
{
for
(
pos
=
0
;
pos
<
components_len
;)
{
if
(
!
strcmp
(
components
[
pos
],
"."
)
||
if
(
strequal
(
components
[
pos
],
"."
)
||
(
!
strcmp
(
components
[
pos
],
".."
)
&&
pos
==
0
))
{
(
strequal
(
components
[
pos
],
".."
)
&&
pos
==
0
))
{
/* eat this element */
/* eat this element */
free
(
components
[
pos
]);
free
(
components
[
pos
]);
memmove
(
&
components
[
pos
],
&
components
[
pos
+
1
],
memmove
(
&
components
[
pos
],
&
components
[
pos
+
1
],
sizeof
(
char
*
)
*
(
components_len
-
pos
));
sizeof
(
char
*
)
*
(
components_len
-
pos
));
components_len
--
;
components_len
--
;
}
else
if
(
!
strcmp
(
components
[
pos
],
".."
))
{
}
else
if
(
strequal
(
components
[
pos
],
".."
))
{
/* eat this and the previous element */
/* eat this and the previous element */
free
(
components
[
pos
-
1
]);
free
(
components
[
pos
-
1
]);
free
(
components
[
pos
]);
free
(
components
[
pos
]);
...
@@ -312,7 +312,7 @@ bool lxc_string_in_list(const char *needle, const char *haystack, char _sep)
...
@@ -312,7 +312,7 @@ bool lxc_string_in_list(const char *needle, const char *haystack, char _sep)
str
=
must_copy_string
(
haystack
);
str
=
must_copy_string
(
haystack
);
lxc_iterate_parts
(
token
,
str
,
sep
)
lxc_iterate_parts
(
token
,
str
,
sep
)
if
(
str
cmp
(
needle
,
token
)
==
0
)
if
(
str
equal
(
needle
,
token
)
)
return
1
;
return
1
;
return
0
;
return
0
;
...
@@ -859,7 +859,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
...
@@ -859,7 +859,7 @@ int parse_byte_size_string(const char *s, int64_t *converted)
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
dup
[
INTTYPE_TO_STRLEN
(
int64_t
)];
char
suffix
[
3
]
=
{
0
};
char
suffix
[
3
]
=
{
0
};
if
(
!
s
||
!
strcmp
(
s
,
""
))
if
(
!
s
||
strequal
(
s
,
""
))
return
ret_errno
(
EINVAL
);
return
ret_errno
(
EINVAL
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
end
=
stpncpy
(
dup
,
s
,
sizeof
(
dup
)
-
1
);
...
...
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