[LU-12814] lov: stripe_count variable set but unused Created: 27/Sep/19  Updated: 28/Jul/22  Resolved: 28/Jul/22

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question/Request Priority: Minor
Reporter: CEA Assignee: Zhenyu Xu
Resolution: Fixed Votes: 0
Labels: None

Rank (Obsolete): 9223372036854775807

 Description   

Compiling with a recent version of gcc and with -Wall -Werrno yields the following error message:

/home/user/lustre-release/lustre/lov/lov_internal.h:130:7: error: variable ‘stripe_count’ set but not used [-Werror=unused-but-set-variable]
   u16 stripe_count;
       ^~~~~~~~~~~~

The code looks like this:

static inline size_t lov_comp_md_size(const struct lov_stripe_md *lsm)
{
        struct lov_stripe_md_entry *lsme;
        size_t size;
        int entry;

        if (lsm->lsm_magic == LOV_MAGIC_V1 || lsm->lsm_magic == LOV_MAGIC_V3)
                return lov_mds_md_size(lsm->lsm_entries[0]->lsme_stripe_count,
                                       lsm->lsm_entries[0]->lsme_magic);

        if (lsm->lsm_magic == LOV_MAGIC_FOREIGN)
                return lsm->lsm_foreign_size;

        LASSERT(lsm->lsm_magic == LOV_MAGIC_COMP_V1);

        size = sizeof(struct lov_comp_md_v1);
        for (entry = 0; entry < lsm->lsm_entry_count; entry++) {
                u16 stripe_count;

                lsme = lsm->lsm_entries[entry];

                if (lsme_inited(lsme))
                        stripe_count = lsme->lsme_stripe_count;
                else
                        stripe_count = 0;

                size += sizeof(*lsme);
                size += lov_mds_md_size(lsme->lsme_stripe_count,
                                        lsme->lsme_magic);
        }

        return size;
}

I am not familiar with the function, but just by considering how it is implemented, I think the lines:

                size += lov_mds_md_size(lsme->lsme_stripe_count,
                                        lsme->lsme_magic);

shoud rather be:

                size += lov_mds_md_size(stripe_count, lsme->lsme_magic);

Can anyone confirm this?



 Comments   
Comment by Peter Jones [ 30/Sep/19 ]

Bobijam

Could you please advise?

Thanks

Peter

Comment by Zhenyu Xu [ 28/Jul/22 ]

with patch https://review.whamcloud.com/#/c/37493/

Generated at Sat Feb 10 02:55:52 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.