This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/29574] New: Gcc gives invalid warning about unitialized variable

Compile Linux 2.6.18 kernel. Warns that idx may be uninitialized in
fs/bio.c:bio_alloc_bioset(), but it clearly *is* being initialized
by bvec_alloc_bs. 

The kernel team will not allow us to pre-initialize these, as it is
a gcc bug. On the other hand, we're drowned in invalid warnings, so
can't see any real problems. Older versions of gcc (3.x) did not
have this problem.

struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
        struct bio *bio = mempool_alloc(bs->bio_pool, gfp_mask);

        if (likely(bio)) {
                struct bio_vec *bvl = NULL;

                if (likely(nr_iovecs)) {
                        unsigned long idx;

                        bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
                        if (unlikely(!bvl)) {
                                mempool_free(bio, bs->bio_pool);
                                bio = NULL;
                                goto out;
                        bio->bi_flags |= idx << BIO_POOL_OFFSET;
                        bio->bi_max_vecs = bvec_slabs[idx].nr_vecs;
                bio->bi_io_vec = bvl;
        return bio;

static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned
long *idx, struct bio_set *bs)
        struct bio_vec *bvl;
        struct biovec_slab *bp;

         * see comment near bvec_array define!
        switch (nr) {
                case   1        : *idx = 0; break;
                case   2 ...   4: *idx = 1; break;
                case   5 ...  16: *idx = 2; break;
                case  17 ...  64: *idx = 3; break;
                case  65 ... 128: *idx = 4; break;
                case 129 ... BIO_MAX_PAGES: *idx = 5; break;
                        return NULL;
         * idx now points to the pool we want to allocate from

        bp = bvec_slabs + *idx;
        bvl = mempool_alloc(bs->bvec_pools[*idx], gfp_mask);
        if (bvl)
                memset(bvl, 0, bp->nr_vecs * sizeof(struct bio_vec));

        return bvl;

           Summary: Gcc gives invalid warning about unitialized variable
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mbligh at mbligh dot org

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]