mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chakravarthikulkarni <chakravarthikulkarni2021@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: chakravarthikulkarni2021@gmail.com,
	David Woodhouse <dwmw2@infradead.org>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs:jffs2: Fixed return statement in if and else statement
Date: Fri, 19 Feb 2021 14:02:12 +0530	[thread overview]
Message-ID: <20210219083214.11583-1-chakravarthikulkarni2021@gmail.com> (raw)

Error:  Fixed Error found by checkpath.pl script.
	switch and case should be at the same indent
Warning: Fixed Warning found by checkpath.pl script.

Signed-off-by: chakravarthikulkarni <chakravarthikulkarni2021@gmail.com>
---
 fs/jffs2/acl.c | 105 ++++++++++++++++++++++++-------------------------
 1 file changed, 52 insertions(+), 53 deletions(-)

diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index 093ffbd82395..e66a1c4eaefd 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -38,18 +38,20 @@ static size_t jffs2_acl_size(int count)
 static int jffs2_acl_count(size_t size)
 {
 	size_t s;
+	int ret = 0;
 
 	size -= sizeof(struct jffs2_acl_header);
 	if (size < 4 * sizeof(struct jffs2_acl_entry_short)) {
 		if (size % sizeof(struct jffs2_acl_entry_short))
 			return -1;
-		return size / sizeof(struct jffs2_acl_entry_short);
+		ret =  size / sizeof(struct jffs2_acl_entry_short);
 	} else {
 		s = size - 4 * sizeof(struct jffs2_acl_entry_short);
 		if (s % sizeof(struct jffs2_acl_entry))
 			return -1;
-		return s / sizeof(struct jffs2_acl_entry) + 4;
+		ret = s / sizeof(struct jffs2_acl_entry) + 4;
 	}
+	return ret;
 }
 
 static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size)
@@ -82,39 +84,37 @@ static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size)
 	if (!acl)
 		return ERR_PTR(-ENOMEM);
 
-	for (i=0; i < count; i++) {
+	for (i = 0; i < count; i++) {
 		entry = value;
 		if (value + sizeof(struct jffs2_acl_entry_short) > end)
 			goto fail;
 		acl->a_entries[i].e_tag = je16_to_cpu(entry->e_tag);
 		acl->a_entries[i].e_perm = je16_to_cpu(entry->e_perm);
 		switch (acl->a_entries[i].e_tag) {
-			case ACL_USER_OBJ:
-			case ACL_GROUP_OBJ:
-			case ACL_MASK:
-			case ACL_OTHER:
-				value += sizeof(struct jffs2_acl_entry_short);
-				break;
-
-			case ACL_USER:
-				value += sizeof(struct jffs2_acl_entry);
-				if (value > end)
-					goto fail;
-				acl->a_entries[i].e_uid =
-					make_kuid(&init_user_ns,
-						  je32_to_cpu(entry->e_id));
-				break;
-			case ACL_GROUP:
-				value += sizeof(struct jffs2_acl_entry);
-				if (value > end)
-					goto fail;
-				acl->a_entries[i].e_gid =
-					make_kgid(&init_user_ns,
-						  je32_to_cpu(entry->e_id));
+		case ACL_USER_OBJ:
+		case ACL_GROUP_OBJ:
+		case ACL_MASK:
+		case ACL_OTHER:
+			value += sizeof(struct jffs2_acl_entry_short);
+			break;
+		case ACL_USER:
+			value += sizeof(struct jffs2_acl_entry);
+			if (value > end)
+				goto fail;
+			acl->a_entries[i].e_uid =
+				make_kuid(&init_user_ns,
+						je32_to_cpu(entry->e_id));
 				break;
-
-			default:
+		case ACL_GROUP:
+			value += sizeof(struct jffs2_acl_entry);
+			if (value > end)
 				goto fail;
+			acl->a_entries[i].e_gid =
+				make_kgid(&init_user_ns,
+						je32_to_cpu(entry->e_id));
+			break;
+		default:
+			goto fail;
 		}
 	}
 	if (value != end)
@@ -139,32 +139,31 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
 		return ERR_PTR(-ENOMEM);
 	header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
 	e = header + 1;
-	for (i=0; i < acl->a_count; i++) {
+	for (i = 0; i < acl->a_count; i++) {
 		const struct posix_acl_entry *acl_e = &acl->a_entries[i];
+
 		entry = e;
 		entry->e_tag = cpu_to_je16(acl_e->e_tag);
 		entry->e_perm = cpu_to_je16(acl_e->e_perm);
-		switch(acl_e->e_tag) {
-			case ACL_USER:
-				entry->e_id = cpu_to_je32(
-					from_kuid(&init_user_ns, acl_e->e_uid));
-				e += sizeof(struct jffs2_acl_entry);
-				break;
-			case ACL_GROUP:
-				entry->e_id = cpu_to_je32(
-					from_kgid(&init_user_ns, acl_e->e_gid));
-				e += sizeof(struct jffs2_acl_entry);
-				break;
-
-			case ACL_USER_OBJ:
-			case ACL_GROUP_OBJ:
-			case ACL_MASK:
-			case ACL_OTHER:
-				e += sizeof(struct jffs2_acl_entry_short);
-				break;
-
-			default:
-				goto fail;
+		switch (acl_e->e_tag) {
+		case ACL_USER:
+			entry->e_id = cpu_to_je32(from_kuid(&init_user_ns,
+						acl_e->e_uid));
+			e += sizeof(struct jffs2_acl_entry);
+			break;
+		case ACL_GROUP:
+			entry->e_id = cpu_to_je32(
+				from_kgid(&init_user_ns, acl_e->e_gid));
+			e += sizeof(struct jffs2_acl_entry);
+			break;
+		case ACL_USER_OBJ:
+		case ACL_GROUP_OBJ:
+		case ACL_MASK:
+		case ACL_OTHER:
+			e += sizeof(struct jffs2_acl_entry_short);
+			break;
+		default:
+			goto fail;
 		}
 	}
 	return header;
@@ -196,13 +195,13 @@ struct posix_acl *jffs2_get_acl(struct inode *inode, int type)
 			return ERR_PTR(-ENOMEM);
 		rc = do_jffs2_getxattr(inode, xprefix, "", value, rc);
 	}
-	if (rc > 0) {
+	if (rc > 0)
 		acl = jffs2_acl_from_medium(value, rc);
-	} else if (rc == -ENODATA || rc == -ENOSYS) {
+	else if (rc == -ENODATA || rc == -ENOSYS)
 		acl = NULL;
-	} else {
+	else
 		acl = ERR_PTR(rc);
-	}
+
 	kfree(value);
 	return acl;
 }
-- 
2.17.1


                 reply	other threads:[~2021-02-19  8:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210219083214.11583-1-chakravarthikulkarni2021@gmail.com \
    --to=chakravarthikulkarni2021@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®