ia64/xen-unstable

changeset 19297:12c19447f6ea

blktap: Fix compile warnings in block-qcow2.c

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 09 09:48:45 2009 +0000 (2009-03-09)
parents 95e3cd67add2
children 5997e86988f6
files tools/blktap/drivers/block-qcow2.c
line diff
     1.1 --- a/tools/blktap/drivers/block-qcow2.c	Mon Mar 09 09:37:52 2009 +0000
     1.2 +++ b/tools/blktap/drivers/block-qcow2.c	Mon Mar 09 09:48:45 2009 +0000
     1.3 @@ -1984,6 +1984,7 @@ int qcow2_create(const char *filename, u
     1.4                        const char *backing_file, int flags)
     1.5  {
     1.6      int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
     1.7 +    int ret = 0;
     1.8      QCowHeader header;
     1.9      uint64_t tmp, offset;
    1.10      QCowCreateState s1, *s = &s1;
    1.11 @@ -2042,25 +2043,37 @@ int qcow2_create(const char *filename, u
    1.12      create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
    1.13  
    1.14      /* write all the data */
    1.15 -    write(fd, &header, sizeof(header));
    1.16 +    ret = write(fd, &header, sizeof(header));
    1.17 +    if (ret < 0)
    1.18 +        goto out;
    1.19      if (backing_file) {
    1.20 -        write(fd, backing_file, backing_filename_len);
    1.21 +        ret = write(fd, backing_file, backing_filename_len);
    1.22 +        if (ret < 0)
    1.23 +            goto out;
    1.24      }
    1.25      lseek(fd, s->l1_table_offset, SEEK_SET);
    1.26      tmp = 0;
    1.27      for(i = 0;i < l1_size; i++) {
    1.28 -        write(fd, &tmp, sizeof(tmp));
    1.29 +        ret = write(fd, &tmp, sizeof(tmp));
    1.30 +        if (ret < 0)
    1.31 +            goto out;
    1.32      }
    1.33      lseek(fd, s->refcount_table_offset, SEEK_SET);
    1.34 -    write(fd, s->refcount_table, s->cluster_size);
    1.35 +    ret = write(fd, s->refcount_table, s->cluster_size);
    1.36 +    if (ret < 0)
    1.37 +        goto out;
    1.38  
    1.39      lseek(fd, s->refcount_block_offset, SEEK_SET);
    1.40 -    write(fd, s->refcount_block, s->cluster_size);
    1.41 +    ret = write(fd, s->refcount_block, s->cluster_size);
    1.42 +    if (ret < 0)
    1.43 +        goto out;
    1.44 +    ret = 0;
    1.45  
    1.46 +  out:
    1.47      qemu_free(s->refcount_table);
    1.48      qemu_free(s->refcount_block);
    1.49      close(fd);
    1.50 -    return 0;
    1.51 +    return ret;
    1.52  }
    1.53  
    1.54