Re: [libvirt] [PATCH 8/9] Simplified version of volume zeroing based on feedback from the list.

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

 



According to David Allan on 3/2/2010 3:13 PM:
> +    ret = ftruncate(fd, st->st_size);
> +    if (ret == -1) {
> +        virReportSystemError(ret,
> +                             _("Failed to truncate volume with "
> +                               "path '%s' to %llu bytes: '%s'\n"),
> +                             vol->target.path, st->st_size,

off_t is not guaranteed to be the same as long long.  You need a cast.

> +                             virStrerror(errno, errbuf, sizeof(errbuf)));
> +    }
> +
> +out:
> +    return ret;
> +}
> +
> +
> +static int
> +storageZeroExtent(virStorageVolDefPtr vol,
> +                  struct stat *st,
> +                  int fd,
> +                  size_t extent_start,
> +                  size_t extent_length,
> +                  char *writebuf,
> +                  size_t *bytes_zeroed)

Is size_t the right type for the extent, or do we want off_t?

> +    size_t remaining, write_size;
...
> +        if (written < 0) {
> +            virReportSystemError(written,
> +                                 _("Failed to write to storage volume with "
> +                                   "path '%s': '%s' "
> +                                   "(attempted to write %d bytes)"),
> +                                 vol->target.path,
> +                                 virStrerror(errno, errbuf, sizeof(errbuf)),
> +                                 write_size);

%d and write_size are not compatible.

> +    memset(&st, 0, sizeof(st));
> +
> +    if (fstat(fd, &st) == -1) {

The memset is wasted work.  stat() is sufficient for initializing st.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]