diff mbox

rbd: Fix uninitialized variable use in rbd_acquire_lock

Message ID 1499931995-64900-1-git-send-email-wangkefeng.wang@huawei.com
State Accepted
Commit 37f13252579389a659ae3ceec8c60f15bdf70f0c
Headers show

Commit Message

Kefeng Wang July 13, 2017, 7:46 a.m. UTC
drivers/block/rbd.c: In function 'rbd_acquire_lock':
drivers/block/rbd.c:3602:44: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Silence the warning, found it when built old kernel(3.10) with
OBS(opensuse build service).

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
1.7.12.4

Comments

Ilya Dryomov July 14, 2017, 10:06 a.m. UTC | #1
On Thu, Jul 13, 2017 at 9:46 AM, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
> drivers/block/rbd.c: In function 'rbd_acquire_lock':

> drivers/block/rbd.c:3602:44: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

>

> Silence the warning, found it when built old kernel(3.10) with

> OBS(opensuse build service).

>

> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

> ---

>  drivers/block/rbd.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c

> index b008b6a..b640ad8 100644

> --- a/drivers/block/rbd.c

> +++ b/drivers/block/rbd.c

> @@ -3435,7 +3435,7 @@ static void rbd_acquire_lock(struct work_struct *work)

>         struct rbd_device *rbd_dev = container_of(to_delayed_work(work),

>                                             struct rbd_device, lock_dwork);

>         enum rbd_lock_state lock_state;

> -       int ret;

> +       int ret = 0;

>

>         dout("%s rbd_dev %p\n", __func__, rbd_dev);

>  again:


How did you get rbd_acquire_lock() into 3.10?

Thanks,

                Ilya
Kefeng Wang July 14, 2017, 11:25 a.m. UTC | #2
On 2017/7/14 18:06, Ilya Dryomov wrote:
> On Thu, Jul 13, 2017 at 9:46 AM, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

>> drivers/block/rbd.c: In function 'rbd_acquire_lock':

>> drivers/block/rbd.c:3602:44: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

>>

>> Silence the warning, found it when built old kernel(3.10) with

>> OBS(opensuse build service).

>>

>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

>> ---

>>  drivers/block/rbd.c | 2 +-

>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c

>> index b008b6a..b640ad8 100644

>> --- a/drivers/block/rbd.c

>> +++ b/drivers/block/rbd.c

>> @@ -3435,7 +3435,7 @@ static void rbd_acquire_lock(struct work_struct *work)

>>         struct rbd_device *rbd_dev = container_of(to_delayed_work(work),

>>                                             struct rbd_device, lock_dwork);

>>         enum rbd_lock_state lock_state;

>> -       int ret;

>> +       int ret = 0;

>>

>>         dout("%s rbd_dev %p\n", __func__, rbd_dev);

>>  again:

> 

> How did you get rbd_acquire_lock() into 3.10?


Using CentOS 7.3.

> 

> Thanks,

> 

>                 Ilya

> 

>
Ilya Dryomov July 17, 2017, 3:08 p.m. UTC | #3
On Fri, Jul 14, 2017 at 1:25 PM, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>

>

> On 2017/7/14 18:06, Ilya Dryomov wrote:

>> On Thu, Jul 13, 2017 at 9:46 AM, Kefeng Wang <wangkefeng.wang@huawei.com> wrote:

>>> drivers/block/rbd.c: In function 'rbd_acquire_lock':

>>> drivers/block/rbd.c:3602:44: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]

>>>

>>> Silence the warning, found it when built old kernel(3.10) with

>>> OBS(opensuse build service).

>>>

>>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

>>> ---

>>>  drivers/block/rbd.c | 2 +-

>>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>>

>>> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c

>>> index b008b6a..b640ad8 100644

>>> --- a/drivers/block/rbd.c

>>> +++ b/drivers/block/rbd.c

>>> @@ -3435,7 +3435,7 @@ static void rbd_acquire_lock(struct work_struct *work)

>>>         struct rbd_device *rbd_dev = container_of(to_delayed_work(work),

>>>                                             struct rbd_device, lock_dwork);

>>>         enum rbd_lock_state lock_state;

>>> -       int ret;

>>> +       int ret = 0;

>>>

>>>         dout("%s rbd_dev %p\n", __func__, rbd_dev);

>>>  again:

>>

>> How did you get rbd_acquire_lock() into 3.10?

>

> Using CentOS 7.3.


Applied.

Thanks,

                Ilya
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b008b6a..b640ad8 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3435,7 +3435,7 @@  static void rbd_acquire_lock(struct work_struct *work)
 	struct rbd_device *rbd_dev = container_of(to_delayed_work(work),
 					    struct rbd_device, lock_dwork);
 	enum rbd_lock_state lock_state;
-	int ret;
+	int ret = 0;
 
 	dout("%s rbd_dev %p\n", __func__, rbd_dev);
 again: