Skip to contentSkip to conversation

Staging: lustre: Removal of Unnecessary white spaces

PATCH In review Monam Agarwal 3 participants 6 messages Jan 11, 2014 – Jan 13, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Staging: lustre: Removal of Unnecessary white spaces

This fixes the following checkpatch.pl warning in lustre/ldlm/ldlm_extent.c
WARNING: unnecessary whitespace before a quoted newline

---
 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -1
index ac5d66a..374d6e4 100644
@@ -153,7 +153,7 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	for (index = -1; mode; index++, mode >>= 1);
 	LASSERT(index < LCK_MODE_NUM);
 	return index;
 }
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 3 lines · Monam Agarwal

This fixes the following checkpatch.pl warning in lustre/ldlm/ldlm_extent.c
WARNING: unnecessary whitespace before a quoted newline

I rather doubt this was the checkpatch message here. Please make sure your commit message and subject match.

[]

drivers/staging/lustre/lustre/ldlm/ldlm_extent.c

Quoted 1 line
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +0 -0

[]

drivers/staging/lustre/lustre/ldlm/ldlm_extent.c static inline int lock_mode_to_index(ldlm_mode_t mode) · line 156

Quoted 6 lines
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -1
@@ -153,7 +153,7 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	for (index = -1; mode; index++, mode >>= 1);

Try using fls instead of this.

#2 lore raw

PATCH v2 1/1 Staging: lustre: Use of fls to find last set bit

In reply to Monam Agarwal

This introduces fls in lustre/ldlm/ldlm_extent.c
to find the last set bit.

It also fixes the following checkpatch.pl warning in lustre/ldlm/ldlm_extent.c
WARNING: space prohibited before semicolon.

The patch also fixes the following checkpatch.pl error in lustre/ldlm/ldlm_extent.c
ERROR: trailing statements should be on next line

---
Changes since v1:
*Incorrect commit message
*Use of fls function

 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +3 -1
index ac5d66a..e6fe2cb 100644
@@ -150,10 +150,12 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l)
 static inline int lock_mode_to_index(ldlm_mode_t mode)
 {
 	int index;
+	int len;
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	len = fls(mode);
+	index = len-1;
 	LASSERT(index < LCK_MODE_NUM);
 	return index;
 }
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH v2] Staging: lustre: Use of fls to find last set bit

Quoted 2 lines · Monam Agarwal

This introduces fls in lustre/ldlm/ldlm_extent.c
to find the last set bit.

[]

Quoted 5 lines

---
Changes since v1:
*Incorrect commit message
*Use of fls function

[]

drivers/staging/lustre/lustre/ldlm/ldlm_extent.c

Quoted 1 line
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +0 -0

[]

drivers/staging/lustre/lustre/ldlm/ldlm_extent.c struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l) · line 158

Quoted 11 lines
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +3 -1
@@ -150,10 +150,12 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l)
 static inline int lock_mode_to_index(ldlm_mode_t mode)
 {
 	int index;
+	int len;
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	len = fls(mode);
+	index = len-1;

There's no need for len at all.

	index = fls(mode) - 1;

would be fine.

#4 lore raw

PATCH v3 1/1 Staging: lustre: Use of fls to find last set bit

In reply to Monam Agarwal

This introduces fls in lustre/ldlm/ldlm_extent.c
to find the last set bit.

---
Changes since v1:
* Incorrect commit message
* Use of fls function
Changes since v2:
* Removal of extra variable

 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -1
index ac5d66a..a4f382d 100644
@@ -153,7 +153,7 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	index = fls(mode)-1;
 	LASSERT(index < LCK_MODE_NUM);
 	return index;
 }
Signature · 1 line
1.7.9.5
#5 lore raw

Re: [PATCH v3] Staging: lustre: Use of fls to find last set bit

Quoted 19 lines · Monam Agarwal

This introduces fls in lustre/ldlm/ldlm_extent.c
to find the last set bit.

---
Changes since v1:
* Incorrect commit message
* Use of fls function
Changes since v2:
* Removal of extra variable

 drivers/staging/lustre/lustre/ldlm/ldlm_extent.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +0 -0
index ac5d66a..a4f382d 100644

drivers/staging/lustre/lustre/ldlm/ldlm_extent.c static inline int lock_mode_to_index(ldlm_mode_t mode) · line 156

Quoted 5 lines
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +1 -1
@@ -153,7 +153,7 @@ static inline int lock_mode_to_index(ldlm_mode_t mode)
 
 	LASSERT(mode != 0);
 	LASSERT(IS_PO2(mode));
-	for (index = -1; mode; index++, mode >>= 1) ;
+	index = fls(mode)-1;

Put spaces around math operations. Just cut and paste what Joe wrote.

regards,
dan carpenter