Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1 view
Skip to first unread message

Monam Agarwal

unread,
Jan 11, 2014, 6:50:02 AM1/11/14
to
This fixes the following checkpatch.pl warning in
lustre/ldlm/ldlm_extent.c
WARNING: unnecessary whitespace before a quoted newline

Signed-off-by: Monam Agarwal <monamag...@gmail.com>
---
drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index ac5d66a..374d6e4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -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;
}
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Joe Perches

unread,
Jan 11, 2014, 12:30:02 PM1/11/14
to
On Sat, 2014-01-11 at 17:11 +0530, Monam Agarwal wrote:
> 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.

[]
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
[]
> @@ -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.

Monam Agarwal

unread,
Jan 11, 2014, 2:40:01 PM1/11/14
to
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


Signed-off-by: Monam Agarwal <monamag...@gmail.com>
---
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(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index ac5d66a..e6fe2cb 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -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;

Joe Perches

unread,
Jan 11, 2014, 3:10:02 PM1/11/14
to
On Sun, 2014-01-12 at 01:02 +0530, Monam Agarwal wrote:
> This introduces fls in lustre/ldlm/ldlm_extent.c
> to find the last set bit.
[]
> Signed-off-by: Monam Agarwal <monamag...@gmail.com>
> ---
> Changes since v1:
> *Incorrect commit message
> *Use of fls function
[]
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
[]
> @@ -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.

Monam Agarwal

unread,
Jan 11, 2014, 3:20:01 PM1/11/14
to
This introduces fls in lustre/ldlm/ldlm_extent.c
to find the last set bit.

Signed-off-by: Monam Agarwal <monamag...@gmail.com>
---
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(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
index ac5d66a..a4f382d 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
@@ -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;

Dan Carpenter

unread,
Jan 13, 2014, 3:30:02 AM1/13/14
to
On Sun, Jan 12, 2014 at 01:45:51AM +0530, Monam Agarwal wrote:
> This introduces fls in lustre/ldlm/ldlm_extent.c
> to find the last set bit.
>
> Signed-off-by: Monam Agarwal <monamag...@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
> index ac5d66a..a4f382d 100644
> --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
> +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
> @@ -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
0 new messages