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
d4d6b0ce
Commit
d4d6b0ce
authored
Nov 25, 2016
by
Christian Brauner
Committed by
Stéphane Graber
Nov 30, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree-wide: remove any variable length arrays
They are pointless and marked optional since C11. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
62eeccac
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
+13
-14
lxc_cgroup.c
src/lxc/tools/lxc_cgroup.c
+2
-3
lxc_unshare.c
src/lxc/tools/lxc_unshare.c
+1
-1
utils.c
src/lxc/utils.c
+5
-6
lxc-test-utils.c
src/tests/lxc-test-utils.c
+5
-4
No files found.
src/lxc/tools/lxc_cgroup.c
View file @
d4d6b0ce
...
@@ -121,9 +121,8 @@ int main(int argc, char *argv[])
...
@@ -121,9 +121,8 @@ int main(int argc, char *argv[])
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
{
}
else
{
int
len
=
4096
;
char
buffer
[
MAXPATHLEN
];
char
buffer
[
len
];
int
ret
=
c
->
get_cgroup_item
(
c
,
state_object
,
buffer
,
MAXPATHLEN
);
int
ret
=
c
->
get_cgroup_item
(
c
,
state_object
,
buffer
,
len
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
ERROR
(
"failed to retrieve value of '%s' for '%s:%s'"
,
ERROR
(
"failed to retrieve value of '%s' for '%s:%s'"
,
state_object
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
state_object
,
my_args
.
lxcpath
[
0
],
my_args
.
name
);
...
...
src/lxc/tools/lxc_unshare.c
View file @
d4d6b0ce
...
@@ -82,7 +82,7 @@ static void usage(char *cmd)
...
@@ -82,7 +82,7 @@ static void usage(char *cmd)
static
bool
lookup_user
(
const
char
*
optarg
,
uid_t
*
uid
)
static
bool
lookup_user
(
const
char
*
optarg
,
uid_t
*
uid
)
{
{
char
name
[
sysconf
(
_SC_LOGIN_NAME_MAX
)
];
char
name
[
MAXPATHLEN
];
struct
passwd
*
pwent
=
NULL
;
struct
passwd
*
pwent
=
NULL
;
if
(
!
optarg
||
(
optarg
[
0
]
==
'\0'
))
if
(
!
optarg
||
(
optarg
[
0
]
==
'\0'
))
...
...
src/lxc/utils.c
View file @
d4d6b0ce
...
@@ -1896,6 +1896,8 @@ int lxc_strmunmap(void *addr, size_t length)
...
@@ -1896,6 +1896,8 @@ int lxc_strmunmap(void *addr, size_t length)
}
}
/* Check whether a signal is blocked by a process. */
/* Check whether a signal is blocked by a process. */
/* /proc/pid-to-str/status\0 = (5 + 21 + 7 + 1) */
#define __PROC_STATUS_LEN (5 + 21 + 7 + 1)
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
)
bool
task_blocking_signal
(
pid_t
pid
,
int
signal
)
{
{
bool
bret
=
false
;
bool
bret
=
false
;
...
@@ -1905,13 +1907,10 @@ bool task_blocking_signal(pid_t pid, int signal)
...
@@ -1905,13 +1907,10 @@ bool task_blocking_signal(pid_t pid, int signal)
int
ret
;
int
ret
;
FILE
*
f
;
FILE
*
f
;
/* The largest integer that can fit into long int is 2^64. This is a
char
status
[
__PROC_STATUS_LEN
];
* 20-digit number. */
size_t
len
=
/* /proc */
5
+
/* /pid-to-str */
21
+
/* /status */
7
+
/* \0 */
1
;
char
status
[
len
];
ret
=
snprintf
(
status
,
len
,
"/proc/%d/status"
,
pid
);
ret
=
snprintf
(
status
,
__PROC_STATUS_LEN
,
"/proc/%d/status"
,
pid
);
if
(
ret
<
0
||
ret
>=
len
)
if
(
ret
<
0
||
ret
>=
__PROC_STATUS_LEN
)
return
bret
;
return
bret
;
f
=
fopen
(
status
,
"r"
);
f
=
fopen
(
status
,
"r"
);
...
...
src/tests/lxc-test-utils.c
View file @
d4d6b0ce
...
@@ -70,13 +70,14 @@ void test_lxc_deslashify(void)
...
@@ -70,13 +70,14 @@ void test_lxc_deslashify(void)
free
(
s
);
free
(
s
);
}
}
/* /proc/int_as_str/ns/mnt\0 = (5 + 21 + 7 + 1) */
#define __MNTNS_LEN (5 + 21 + 7 + 1)
void
test_detect_ramfs_rootfs
(
void
)
void
test_detect_ramfs_rootfs
(
void
)
{
{
size_t
i
;
size_t
i
;
int
ret
;
int
ret
;
int
fret
=
EXIT_FAILURE
;
int
fret
=
EXIT_FAILURE
;
size_t
len
=
5
/* /proc */
+
21
/* /int_as_str */
+
7
/* /ns/mnt */
+
1
/* \0 */
;
char
path
[
__MNTNS_LEN
];
char
path
[
len
];
int
init_ns
=
-
1
;
int
init_ns
=
-
1
;
char
tmpf1
[]
=
"lxc-test-utils-XXXXXX"
;
char
tmpf1
[]
=
"lxc-test-utils-XXXXXX"
;
char
tmpf2
[]
=
"lxc-test-utils-XXXXXX"
;
char
tmpf2
[]
=
"lxc-test-utils-XXXXXX"
;
...
@@ -118,8 +119,8 @@ void test_detect_ramfs_rootfs(void)
...
@@ -118,8 +119,8 @@ void test_detect_ramfs_rootfs(void)
"78 24 8:1 / /boot/efi rw,relatime shared:30 - vfat /dev/sda1 rw,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro"
,
"78 24 8:1 / /boot/efi rw,relatime shared:30 - vfat /dev/sda1 rw,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro"
,
};
};
ret
=
snprintf
(
path
,
len
,
"/proc/self/ns/mnt"
);
ret
=
snprintf
(
path
,
__MNTNS_LEN
,
"/proc/self/ns/mnt"
);
if
(
ret
<
0
||
(
size_t
)
ret
>=
len
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
__MNTNS_LEN
)
{
lxc_error
(
"%s
\n
"
,
"Failed to create path with snprintf()."
);
lxc_error
(
"%s
\n
"
,
"Failed to create path with snprintf()."
);
goto
non_test_error
;
goto
non_test_error
;
}
}
...
...
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