Skip to contentSkip to conversation

Staging: lustre: Remove unnecessary braces of single statement block

PATCH In review Sandhya Bankar 2 participants 2 messages Feb 21, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: Remove unnecessary braces of single statement block

Remove unnecessary braces of single statement block else

---
 drivers/staging/lustre/lustre/llite/dcache.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/llite/dcache.c +2 -4
index bc179e5..e3b98b7 100644
@@ -193,13 +193,11 @@ int ll_d_init(struct dentry *de)
 			if (likely(!de->d_fsdata)) {
 				de->d_fsdata = lld;
 				__d_lustre_invalidate(de);
-			} else {
+			} else
 				kfree(lld);
-			}
 			spin_unlock(&de->d_lock);
-		} else {
+		} else
 			return -ENOMEM;
-		}
 	}
 	LASSERT(de->d_op == &ll_d_ops);
 
Signature · 1 line
1.8.3.4
#1 lore raw
Quoted 1 line · Sandhya Bankar

Remove unnecessary braces of single statement block else

Actually, the rule is that if one branch has braces, the other should too. Documentation/CodingStyle says the following:

Do not unnecessarily use braces where a single statement will do.

        if (condition)
		action();

and

	if (condition)
                do_this();
	else
                do_that();

This does not apply if only one branch of a conditional statement is a single statement; in the latter case use braces in both branches:

        if (condition) {
                do_this();
		do_that();
        } else {
                otherwise();
        }

julia

Quoted 37 lines
---
 drivers/staging/lustre/lustre/llite/dcache.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/llite/dcache.c +2 -5
index bc179e5..e3b98b7 100644
@@ -193,13 +193,11 @@ int ll_d_init(struct dentry *de)
 			if (likely(!de->d_fsdata)) {
 				de->d_fsdata = lld;
 				__d_lustre_invalidate(de);
-			} else {
+			} else
 				kfree(lld);
-			}
 			spin_unlock(&de->d_lock);
-		} else {
+		} else
 			return -ENOMEM;
-		}
 	}
 	LASSERT(de->d_op == &ll_d_ops);
 
--

1.8.3.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160221041414.GA2801%40sandhya.
For more options, visit https://groups.google.com/d/optout.