[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libvir] PATCH: 14/16: disk partition backend



"Daniel P. Berrange" <berrange redhat com> wrote:
> +static int virStorageBackendDiskCreateVol(virConnectPtr conn,
> +                                          virStoragePoolObjPtr pool,
> +                                          virStorageVolDefPtr vol)
> +{
> +    int i;
> +    char start[100], end[100];
> +    unsigned long long startOffset, endOffset, smallestSize = 0, smallestExtent = -1;

[Past column 80 -> harder to spot]
unsigned... = -1; ?

How about this instead, since smallestExtent only ever
gets set to values stored in "i" (an int)?

    int smallestExtent = -1;

> +    virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
> +    /* XXX customizable partition types */
> +    const char *cmdargv[] = {
> +        PARTED,
> +        pool->def->source.devices[0].path,
> +        "mkpart",
> +        "--script",
> +        "ext2",
> +        start,
> +        end,
> +        NULL
> +    };
> +
> +    for (i = 0 ; i < dev->nfreeExtent ; i++) {
> +        unsigned long long size =
> +            dev->freeExtents[i].end -
> +            dev->freeExtents[i].start;

Shouldn't size be 1 larger?  i.e.,

        unsigned long long size =
            dev->freeExtents[i].end -
            dev->freeExtents[i].start + 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]