ip: code cleanup
Run all the ip code through checkpatch and have it fix the obvious stuff.
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 4ce5989..71fbfce 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -389,6 +389,7 @@
static int on_netns_exec(char *nsname, void *arg)
{
char **argv = arg;
+
cmd_exec(argv[1], argv + 1, true);
return 0;
}
@@ -426,6 +427,7 @@
static int is_pid(const char *str)
{
int ch;
+
for (; (ch = *str); str++) {
if (!isdigit(ch))
return 0;
@@ -470,9 +472,10 @@
strerror(errno));
return -1;
}
- while((entry = readdir(dir))) {
+ while ((entry = readdir(dir))) {
char pid_net_path[PATH_MAX];
struct stat st;
+
if (!is_pid(entry->d_name))
continue;
snprintf(pid_net_path, sizeof(pid_net_path), "/proc/%s/ns/net",
@@ -535,7 +538,7 @@
return -1;
}
- while((entry = readdir(dir))) {
+ while ((entry = readdir(dir))) {
char name_path[PATH_MAX];
struct stat st;
@@ -737,6 +740,7 @@
char buf[4096];
struct inotify_event *event;
int fd;
+
fd = inotify_init();
if (fd < 0) {
fprintf(stderr, "inotify_init failed: %s\n",
@@ -752,8 +756,9 @@
strerror(errno));
return -1;
}
- for(;;) {
+ for (;;) {
ssize_t len = read(fd, buf, sizeof(buf));
+
if (len < 0) {
fprintf(stderr, "read failed: %s\n",
strerror(errno));