Patchwork bitops: fix test_and_change_bit()

login
register
mail settings
Submitter Corentin Chary
Date Feb. 24, 2011, 10:47 p.m.
Message ID <1298587628-18187-1-git-send-email-corentincj@iksaif.net>
Download mbox | patch
Permalink /patch/84496/
State New
Headers show

Comments

Corentin Chary - Feb. 24, 2011, 10:47 p.m.
./bitops.h:192: warning: ‘old’ is used uninitialized in this function

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 bitops.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Blue Swirl - Feb. 25, 2011, 6:07 p.m.
Thanks, applied.

On Fri, Feb 25, 2011 at 12:47 AM, Corentin Chary <corentincj@iksaif.net> wrote:
> ./bitops.h:192: warning: ‘old’ is used uninitialized in this function
>
> Signed-off-by: Corentin Chary <corentincj@iksaif.net>
> ---
>  bitops.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/bitops.h b/bitops.h
> index ae7bcb1..e2b9df3 100644
> --- a/bitops.h
> +++ b/bitops.h
> @@ -187,7 +187,7 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
>  {
>        unsigned long mask = BIT_MASK(nr);
>        unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
> -       unsigned long old;
> +       unsigned long old = *p;
>
>        *p = old ^ mask;
>        return (old & mask) != 0;
> --
> 1.7.4.1
>
>
>

Patch

diff --git a/bitops.h b/bitops.h
index ae7bcb1..e2b9df3 100644
--- a/bitops.h
+++ b/bitops.h
@@ -187,7 +187,7 @@  static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
 {
 	unsigned long mask = BIT_MASK(nr);
 	unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
-	unsigned long old;
+	unsigned long old = *p;
 
 	*p = old ^ mask;
 	return (old & mask) != 0;