[lvm-devel] [PATCH 03/14] Refactor and add code for (lv) 'origin_size' get function.
Dave Wysochanski
dwysocha at redhat.com
Tue Oct 12 14:22:46 UTC 2010
On Mon, 2010-10-11 at 20:13 +0200, Petr Rockai wrote:
> Dave Wysochanski <dwysocha at redhat.com> writes:
>
> > Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
> Reviewed-By: Petr Rockai <prockai at redhat.com>
>
> >
> > +uint64_t lv_origin_size(const struct logical_volume *lv)
> > +{
> > + uint64_t size;
> > +
> > + if (lv_is_cow(lv))
> > + size = (uint64_t) find_cow(lv)->len * lv->vg->extent_size;
> > + else if (lv_is_origin(lv))
> > + size = lv->size;
> > + else
> > + size = UINT64_C(0);
> > + return size;
> > +}
> You don't need the UINT64_C there. size = 0 will work, you know. :)
> Also, I would be inclined to write instead:
>
> uint64_t lv_origin_size(const struct logical_volume *lv)
> {
> if (lv_is_cow(lv))
> return (uint64_t) find_cow(lv)->len * lv->vg->extent_size;
> if (lv_is_origin(lv))
> return lv->size;
> return 0;
> }
>
> which has the same effect.
>
Very good. An excellent cleanup - thanks.
More information about the lvm-devel
mailing list