ext2: unindent codeblock in ext2_xattr_set()
authorJan Kara <jack@suse.cz>
Tue, 12 Jul 2022 10:54:26 +0000 (12:54 +0200)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 3 Aug 2022 03:56:25 +0000 (23:56 -0400)
Replace one else in ext2_xattr_set() with a goto. This makes following
code changes simpler to follow. No functional changes.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://lore.kernel.org/r/20220712105436.32204-7-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext2/xattr.c

index 9885294993efb3c4130c4af14613f6a1f446f901..37ce495eb2798335523705743a3ac98220593e01 100644 (file)
@@ -517,7 +517,8 @@ bad_block:
        /* Here we know that we can set the new attribute. */
 
        if (header) {
-               /* assert(header == HDR(bh)); */
+               int offset;
+
                lock_buffer(bh);
                if (header->h_refcount == cpu_to_le32(1)) {
                        __u32 hash = le32_to_cpu(header->h_hash);
@@ -531,22 +532,20 @@ bad_block:
                                              bh->b_blocknr);
 
                        /* keep the buffer locked while modifying it. */
-               } else {
-                       int offset;
-
-                       unlock_buffer(bh);
-                       ea_bdebug(bh, "cloning");
-                       header = kmemdup(HDR(bh), bh->b_size, GFP_KERNEL);
-                       error = -ENOMEM;
-                       if (header == NULL)
-                               goto cleanup;
-                       header->h_refcount = cpu_to_le32(1);
-
-                       offset = (char *)here - bh->b_data;
-                       here = ENTRY((char *)header + offset);
-                       offset = (char *)last - bh->b_data;
-                       last = ENTRY((char *)header + offset);
+                       goto update_block;
                }
+               unlock_buffer(bh);
+               ea_bdebug(bh, "cloning");
+               header = kmemdup(HDR(bh), bh->b_size, GFP_KERNEL);
+               error = -ENOMEM;
+               if (header == NULL)
+                       goto cleanup;
+               header->h_refcount = cpu_to_le32(1);
+
+               offset = (char *)here - bh->b_data;
+               here = ENTRY((char *)header + offset);
+               offset = (char *)last - bh->b_data;
+               last = ENTRY((char *)header + offset);
        } else {
                /* Allocate a buffer where we construct the new block. */
                header = kzalloc(sb->s_blocksize, GFP_KERNEL);
@@ -559,6 +558,7 @@ bad_block:
                last = here = ENTRY(header+1);
        }
 
+update_block:
        /* Iff we are modifying the block in-place, bh is locked here. */
 
        if (not_found) {