Commit 80287d7d by 2xsec

tools: lxc-device: remove the trailing . & fix coding style of strncmp

Signed-off-by: 's avatar2xsec <dh48.jeong@samsung.com>
parent 8f0bdb05
...@@ -64,7 +64,7 @@ static bool is_interface(const char *dev_name, pid_t pid) ...@@ -64,7 +64,7 @@ static bool is_interface(const char *dev_name, pid_t pid)
{ {
pid_t p = fork(); pid_t p = fork();
if (p < 0) { if (p < 0) {
ERROR("Failed to fork task."); ERROR("Failed to fork task");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -72,7 +72,7 @@ static bool is_interface(const char *dev_name, pid_t pid) ...@@ -72,7 +72,7 @@ static bool is_interface(const char *dev_name, pid_t pid)
struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL; struct ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
if (!switch_to_ns(pid, "net")) { if (!switch_to_ns(pid, "net")) {
ERROR("Failed to enter netns of container."); ERROR("Failed to enter netns of container");
_exit(-1); _exit(-1);
} }
...@@ -84,7 +84,7 @@ static bool is_interface(const char *dev_name, pid_t pid) ...@@ -84,7 +84,7 @@ static bool is_interface(const char *dev_name, pid_t pid)
/* Iterate through the interfaces */ /* Iterate through the interfaces */
for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) { for (tempIfAddr = interfaceArray; tempIfAddr != NULL; tempIfAddr = tempIfAddr->ifa_next) {
if (!strncmp(tempIfAddr->ifa_name, dev_name, strlen(tempIfAddr->ifa_name))) if (strncmp(tempIfAddr->ifa_name, dev_name, strlen(tempIfAddr->ifa_name)) == 0)
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
} }
...@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) ...@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
} }
if (!c->is_running(c)) { if (!c->is_running(c)) {
ERROR("Container %s is not running.", c->name); ERROR("Container %s is not running", c->name);
goto err1; goto err1;
} }
...@@ -163,7 +163,7 @@ int main(int argc, char *argv[]) ...@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
else else
dst_name = my_args.argv[2]; dst_name = my_args.argv[2];
if (!strncmp(cmd, "add", strlen(cmd))) { if (strncmp(cmd, "add", strlen(cmd)) == 0) {
if (is_interface(dev_name, 1)) { if (is_interface(dev_name, 1)) {
ret = c->attach_interface(c, dev_name, dst_name); ret = c->attach_interface(c, dev_name, dst_name);
} else { } else {
...@@ -171,10 +171,10 @@ int main(int argc, char *argv[]) ...@@ -171,10 +171,10 @@ int main(int argc, char *argv[])
} }
if (ret != true) { if (ret != true) {
ERROR("Failed to add %s to %s.", dev_name, c->name); ERROR("Failed to add %s to %s", dev_name, c->name);
goto err1; goto err1;
} }
} else if (!strncmp(cmd, "del", strlen(cmd))) { } else if (strncmp(cmd, "del", strlen(cmd)) == 0) {
if (is_interface(dev_name, c->init_pid(c))) { if (is_interface(dev_name, c->init_pid(c))) {
ret = c->detach_interface(c, dev_name, dst_name); ret = c->detach_interface(c, dev_name, dst_name);
} else { } else {
...@@ -182,7 +182,7 @@ int main(int argc, char *argv[]) ...@@ -182,7 +182,7 @@ int main(int argc, char *argv[])
} }
if (ret != true) { if (ret != true) {
ERROR("Failed to del %s from %s.", dev_name, c->name); ERROR("Failed to del %s from %s", dev_name, c->name);
goto err1; goto err1;
} }
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment