From 751d9dcd3904a45fcbad5d253498dadc401736af Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Tue, 12 Oct 2010 10:52:47 +0200 Subject: [PATCH] fix Coding Style Fix the coding style, 80 chars lines, etc ... Fix indentation blocks if ... then ... else ... fi Signed-off-by: Daniel Lezcano --- src/lxc/conf.c | 78 +++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 4f1b46c19..87d326522 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -186,51 +186,61 @@ static struct caps_opt caps_opt[] = { { "mac_admin", CAP_MAC_ADMIN }, }; -static int run_script(const char *name, const char *section, const char *script, ...) +static int run_script(const char *name, const char *section, + const char *script, ...) { va_list argp; int vargc = 4; + int status = 0; + /* count variable arguments and add 4 for script, container * and section name as well as the terminating NULL */ va_start(argp, script); while (va_arg(argp, char*)) vargc++; va_end(argp); - INFO("Executing script '%s' for container '%s', config section '%s'", script, name, section); + + INFO("Executing script '%s' for container '%s', config section '%s'", + script, name, section); int pid = fork(); if (pid < 0) { ERROR("Error forking"); - } else if (pid == 0) { + return -1; + } + + if (pid == 0) { + /* prepare command line arguments */ char *args[vargc]; int i; args[0] = strdup(script); args[1] = strdup(name); args[2] = strdup(section); + va_start(argp, script); - for (i=3; iupscript) { - err = run_script(handler->name, "net", netdev->upscript, "up", "veth", - veth1, (char*) NULL); - if (err) { - ERROR("Failed to run script '%s' for container '%s' and interface '%s'", - netdev->upscript, handler->name, veth1); + err = run_script(handler->name, "net", netdev->upscript, "up", + "veth", veth1, (char*) NULL); + if (err) goto out_delete; - } } DEBUG("instanciated veth '%s/%s', index is '%d'", @@ -1370,13 +1377,10 @@ static int instanciate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n } if (netdev->upscript) { - err = run_script(handler->name, "net", netdev->upscript, "up", "macvlan", - netdev->link, (char*) NULL); - if (err) { - ERROR("Failed to run script '%s' for container '%s' and interface '%s'", - netdev->upscript, handler->name, netdev->link); + err = run_script(handler->name, "net", netdev->upscript, "up", + "macvlan", netdev->link, (char*) NULL); + if (err) return -1; - } } DEBUG("instanciated macvlan '%s', index is '%d' and mode '%d'", @@ -1433,13 +1437,10 @@ static int instanciate_phys(struct lxc_handler *handler, struct lxc_netdev *netd if (netdev->upscript) { int err; - err = run_script(handler->name, "net", netdev->upscript, "up", "phys", - netdev->link, (char*) NULL); - if (err) { - ERROR("Failed to run script '%s' for container '%s' and interface '%s'", - netdev->upscript, handler->name, netdev->link); + err = run_script(handler->name, "net", netdev->upscript, + "up", "phys", netdev->link, (char*) NULL); + if (err) return -1; - } } return 0; @@ -1450,11 +1451,10 @@ static int instanciate_empty(struct lxc_handler *handler, struct lxc_netdev *net netdev->ifindex = 0; if (netdev->upscript) { int err; - err = run_script(handler->name, "net", netdev->upscript, "up", "empty", (char*) NULL); - if (err) { - ERROR("Failed to run script '%s' for container '%s'", netdev->upscript, handler->name); + err = run_script(handler->name, "net", netdev->upscript, + "up", "empty", (char*) NULL); + if (err) return -1; - } } return 0; } -- 2.47.2