Skip to contentSkip to conversation

userns: Fix a kernel coding style issue

PATCH In review Yadav Lamichhane 2 participants 2 messages Jul 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 userns: Fix a kernel coding style issue

fix a brace around if-else statement and for loop.

---
 kernel/user_namespace.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/user_namespace.c +3 -6
index 87804e0371fe..7703753cac97 100644
@@ -118,9 +118,8 @@ int create_user_ns(struct cred *new)
 	ns->owner = owner;
 	ns->group = group;
 	INIT_WORK(&ns->work, free_user_ns);
-	for (i = 0; i < UCOUNT_COUNTS; i++) {
+	for (i = 0; i < UCOUNT_COUNTS; i++)
 		ns->ucount_max[i] = INT_MAX;
-	}
 	ns->ucounts = ucounts;
 
 	/* Inherit USERNS_SETGROUPS_ALLOWED from our parent */
@@ -1156,12 +1155,10 @@ ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
 	if (strncmp(pos, "allow", 5) == 0) {
 		pos += 5;
 		setgroups_allowed = true;
-	}
-	else if (strncmp(pos, "deny", 4) == 0) {
+	} else if (strncmp(pos, "deny", 4) == 0) {
 		pos += 4;
 		setgroups_allowed = false;
-	}
-	else
+	} else
 		goto out;
 
 	/* Verify there is not trailing junk on the line */

--
2.26.2

#1 lore raw
Quoted 25 lines · Yadav Lamichhane

fix a brace around if-else statement and for loop.

---
 kernel/user_namespace.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
kernel/user_namespace.c +1 -2
index 87804e0371fe..7703753cac97 100644
@@ -118,9 +118,8 @@ int create_user_ns(struct cred *new)
 	ns->owner = owner;
 	ns->group = group;
 	INIT_WORK(&ns->work, free_user_ns);
-	for (i = 0; i < UCOUNT_COUNTS; i++) {
+	for (i = 0; i < UCOUNT_COUNTS; i++)
 		ns->ucount_max[i] = INT_MAX;
-	}
 	ns->ucounts = ucounts;
 
 	/* Inherit USERNS_SETGROUPS_ALLOWED from our parent */
@@ -1156,12 +1155,10 @@ ssize_t proc_setgroups_write(struct file *file, const char __user *buf,
 	if (strncmp(pos, "allow", 5) == 0) {
 		pos += 5;

kernel/user_namespace.c ssize_t proc_setgroups_write(struct file *file, const char __user *buf, · line 1162

Quoted 10 lines
kernel/user_namespace.c +2 -4
 		setgroups_allowed = true;
-	}
-	else if (strncmp(pos, "deny", 4) == 0) {
+	} else if (strncmp(pos, "deny", 4) == 0) {
 		pos += 4;
 		setgroups_allowed = false;
-	}
-	else
+	} else
 		goto out;

Kernel coding style would mandate that the else be enclosed in {} as well.

Christian