chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unify parse_argv style
[elogind.git]
/
src
/
nspawn
/
nspawn.c
diff --git
a/src/nspawn/nspawn.c
b/src/nspawn/nspawn.c
index e75cc28074ac1b01bca67b005d0588e2670c507b..76e86b7e05ea1593c2f9be3374840df574580adb 100644
(file)
--- a/
src/nspawn/nspawn.c
+++ b/
src/nspawn/nspawn.c
@@
-166,8
+166,7
@@
static unsigned long arg_personality = 0xffffffffLU;
static const char *arg_image = NULL;
static Volatile arg_volatile = VOLATILE_NO;
static const char *arg_image = NULL;
static Volatile arg_volatile = VOLATILE_NO;
-static int help(void) {
-
+static void help(void) {
printf("%s [OPTIONS...] [PATH] [ARGUMENTS...]\n\n"
"Spawn a minimal namespace container for debugging, testing and building.\n\n"
" -h --help Show this help\n"
printf("%s [OPTIONS...] [PATH] [ARGUMENTS...]\n\n"
"Spawn a minimal namespace container for debugging, testing and building.\n\n"
" -h --help Show this help\n"
@@
-216,8
+215,6
@@
static int help(void) {
" the service unit nspawn is running in\n"
" --volatile[=MODE] Run the system in volatile mode\n",
program_invocation_short_name);
" the service unit nspawn is running in\n"
" --volatile[=MODE] Run the system in volatile mode\n",
program_invocation_short_name);
-
- return 0;
}
static int parse_argv(int argc, char *argv[]) {
}
static int parse_argv(int argc, char *argv[]) {
@@
-285,12
+282,13
@@
static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "+hD:u:bL:M:jS:Z:qi:", options, NULL)) >= 0)
{
+ while ((c = getopt_long(argc, argv, "+hD:u:bL:M:jS:Z:qi:", options, NULL)) >= 0)
switch (c) {
case 'h':
switch (c) {
case 'h':
- return help();
+ help();
+ return 0;
case ARG_VERSION:
puts(PACKAGE_STRING);
case ARG_VERSION:
puts(PACKAGE_STRING);
@@
-395,7
+393,7
@@
static int parse_argv(int argc, char *argv[]) {
case ARG_CAPABILITY:
case ARG_DROP_CAPABILITY: {
case ARG_CAPABILITY:
case ARG_DROP_CAPABILITY: {
- char *state, *word;
+ c
onst c
har *state, *word;
size_t length;
FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) {
size_t length;
FOREACH_WORD_SEPARATOR(word, length, optarg, ",", state) {
@@
-593,7
+591,6
@@
static int parse_argv(int argc, char *argv[]) {
default:
assert_not_reached("Unhandled option");
}
default:
assert_not_reached("Unhandled option");
}
- }
if (arg_share_system)
arg_register = false;
if (arg_share_system)
arg_register = false;
@@
-1659,11
+1656,8
@@
static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
- if (arg_network_bridge)
- memcpy(iface_name, "vb-", 3);
- else
- memcpy(iface_name, "ve-", 3);
- strncpy(iface_name+3, arg_machine, IFNAMSIZ - 3);
+ snprintf(iface_name, IFNAMSIZ, "%s-%s",
+ arg_network_bridge ? "vb" : "ve", arg_machine);
r = get_mac(&mac);
if (r < 0) {
r = get_mac(&mac);
if (r < 0) {
@@
-2602,7
+2596,8
@@
static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
}
static int change_uid_gid(char **_home) {
}
static int change_uid_gid(char **_home) {
- char line[LINE_MAX], *w, *x, *state, *u, *g, *h;
+ char line[LINE_MAX], *x, *u, *g, *h;
+ const char *word, *state;
_cleanup_free_ uid_t *uids = NULL;
_cleanup_free_ char *home = NULL;
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ uid_t *uids = NULL;
_cleanup_free_ char *home = NULL;
_cleanup_fclose_ FILE *f = NULL;
@@
-2752,10
+2747,10
@@
static int change_uid_gid(char **_home) {
x += strcspn(x, WHITESPACE);
x += strspn(x, WHITESPACE);
x += strcspn(x, WHITESPACE);
x += strspn(x, WHITESPACE);
- FOREACH_WORD(w, l, x, state) {
+ FOREACH_WORD(w
ord
, l, x, state) {
char c[l+1];
char c[l+1];
- memcpy(c, w, l);
+ memcpy(c, w
ord
, l);
c[l] = 0;
if (!GREEDY_REALLOC(uids, sz, n_uids+1))
c[l] = 0;
if (!GREEDY_REALLOC(uids, sz, n_uids+1))
@@
-3073,13
+3068,13
@@
int main(int argc, char *argv[]) {
for (;;) {
ContainerStatus container_status;
for (;;) {
ContainerStatus container_status;
- _
barrier_destroy_ Barrier barrier = { }
;
+ _
cleanup_(barrier_destroy) Barrier barrier = BARRIER_NULL
;
struct sigaction sa = {
.sa_handler = nop_handler,
.sa_flags = SA_NOCLDSTOP,
};
struct sigaction sa = {
.sa_handler = nop_handler,
.sa_flags = SA_NOCLDSTOP,
};
- r = barrier_
init
(&barrier);
+ r = barrier_
create
(&barrier);
if (r < 0) {
log_error("Cannot initialize IPC barrier: %s", strerror(-r));
goto finish;
if (r < 0) {
log_error("Cannot initialize IPC barrier: %s", strerror(-r));
goto finish;