block: cleanup bio_alloc_bioset()

this warning (which got fixed by commit b2bf968):

  fs/bio.c: In function ‘bio_alloc_bioset’:
  fs/bio.c:305: warning: ‘p’ may be used uninitialized in this function

Triggered because the code flow in bio_alloc_bioset() is correct
but a bit complex for the compiler to see through.

Streamline it a bit - this also makes the code a tiny bit more compact:

   text	   data	    bss	    dec	    hex	filename
   7540	    256	     40	   7836	   1e9c	bio.o.before
   7539	    256	     40	   7835	   1e9b	bio.o.after

Also remove an older compiler-warnings annotation from this function,
it's not needed.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
Ingo Molnar 2009-02-21 11:16:36 +01:00 committed by Jens Axboe
parent 8e0ee43bc2
commit 34053979fb

View File

@ -301,48 +301,51 @@ void bio_init(struct bio *bio)
**/
struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
{
struct bio_vec *bvl = NULL;
struct bio *bio = NULL;
void *uninitialized_var(p);
unsigned long idx = 0;
void *p = NULL;
if (bs) {
p = mempool_alloc(bs->bio_pool, gfp_mask);
if (p)
if (!p)
goto err;
bio = p + bs->front_pad;
} else
} else {
bio = kmalloc(sizeof(*bio), gfp_mask);
if (likely(bio)) {
struct bio_vec *bvl = NULL;
if (!bio)
goto err;
}
bio_init(bio);
if (likely(nr_iovecs)) {
unsigned long uninitialized_var(idx);
if (unlikely(!nr_iovecs))
goto out_set;
if (nr_iovecs <= BIO_INLINE_VECS) {
idx = 0;
bvl = bio->bi_inline_vecs;
nr_iovecs = BIO_INLINE_VECS;
} else {
bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx,
bs);
bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
if (unlikely(!bvl))
goto err_free;
nr_iovecs = bvec_nr_vecs(idx);
}
if (unlikely(!bvl)) {
bio->bi_flags |= idx << BIO_POOL_OFFSET;
bio->bi_max_vecs = nr_iovecs;
out_set:
bio->bi_io_vec = bvl;
return bio;
err_free:
if (bs)
mempool_free(p, bs->bio_pool);
else
kfree(bio);
bio = NULL;
goto out;
}
bio->bi_flags |= idx << BIO_POOL_OFFSET;
bio->bi_max_vecs = nr_iovecs;
}
bio->bi_io_vec = bvl;
}
out:
return bio;
err:
return NULL;
}
struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs)