Skip to contentSkip to conversation

drivers/block/aoe: using uninitialized variable.

Suggestion Chen Gang 3 participants 3 messages Mar 27, 2013 – Mar 28, 2013

lore
Share & tools
lore

Chen Gang

author
#0 lore raw

Hello Ed L. Cashin

when compiling with EXTRA_CFLAGS=-W

get the warning:
drivers/block/aoe/aoecmd.c:931:20: warning: ‘bv’ is used uninitialized in this function [-Wuninitialized]

bv is really not initialized.

    (and it seems only set "buf->bv_resid = 0" is not enough).

thanks.

gchen.

919 static void
920 bufinit(struct buf *buf, struct request *rq, struct bio *bio) 921 {
922 struct bio_vec *bv;
923

 924         memset(buf, 0, sizeof(*buf));
 925         buf->rq = rq;
 926         buf->bio = bio;
 927         buf->resid = bio->bi_size;
 928         buf->sector = bio->bi_sector;
 929         bio_pageinc(bio);
 930         buf->bv = bio_iovec(bio);
 931         buf->bv_resid = bv->bv_len;
 932         WARN_ON(buf->bv_resid == 0);

933 }

#1 lore raw

Thanks. Jens Axboe said about it to Dan Carpenter that ...

Quoted 1 line

It was fixed up yesterday, it was a merge error in the for-next branch.

Quoted 31 lines · Chen Gang

Hello Ed L. Cashin

when compiling with EXTRA_CFLAGS=-W

get the warning:
drivers/block/aoe/aoecmd.c:931:20: warning: ‘bv’ is used uninitialized in this function [-Wuninitialized]

bv is really not initialized.
(and it seems only set "buf->bv_resid = 0" is not enough).

thanks.

gchen.

919 static void
920 bufinit(struct buf *buf, struct request *rq, struct bio *bio) 921 {
922 struct bio_vec *bv;
923

924         memset(buf, 0, sizeof(*buf));
925         buf->rq = rq;
926         buf->bio = bio;
927         buf->resid = bio->bi_size;
928         buf->sector = bio->bi_sector;
929         bio_pageinc(bio);
930         buf->bv = bio_iovec(bio);
931         buf->bv_resid = bv->bv_len;
932         WARN_ON(buf->bv_resid == 0);

933 }

Signature · 2 lines
  Ed Cashin
  [email protected]
#2 lore raw
Quoted 3 lines · Ed Cashin

Thanks. Jens Axboe said about it to Dan Carpenter that ...

Quoted 1 line
Quoted 1 line

It was fixed up yesterday, it was a merge error in the for-next branch.

thanks.

:-)

Signature · 3 lines
Chen Gang

Flying Transformer