ia64/xen-unstable

changeset 15209:965bf43c9f11

blktap: Fix compile errors

When compiling the various blktap drivers with warnings cranked up, I
get errors that return values are not checked.

Signed-off-by: Charles Coffing <ccoffing@novell.com>
author kfraser@localhost.localdomain
date Thu May 24 14:07:40 2007 +0100 (2007-05-24)
parents f07c1bb86d6c
children 1fde9ebb8019
files tools/blktap/drivers/blktapctrl.c tools/blktap/drivers/block-qcow.c tools/blktap/drivers/block-vmdk.c
line diff
     1.1 --- a/tools/blktap/drivers/blktapctrl.c	Thu May 24 14:05:58 2007 +0100
     1.2 +++ b/tools/blktap/drivers/blktapctrl.c	Thu May 24 14:07:40 2007 +0100
     1.3 @@ -678,7 +678,10 @@ int main(int argc, char *argv[])
     1.4  	__init_blkif();
     1.5  	snprintf(buf, sizeof(buf), "BLKTAPCTRL[%d]", getpid());
     1.6  	openlog(buf, LOG_CONS|LOG_ODELAY, LOG_DAEMON);
     1.7 -	daemon(0,0);
     1.8 +	if (daemon(0,0)) {
     1.9 +		DPRINTF("daemon failed (%d)\n", errno);
    1.10 +		goto open_failed;
    1.11 +	}
    1.12  
    1.13  	print_drivers();
    1.14  	init_driver_list();
     2.1 --- a/tools/blktap/drivers/block-qcow.c	Thu May 24 14:05:58 2007 +0100
     2.2 +++ b/tools/blktap/drivers/block-qcow.c	Thu May 24 14:07:40 2007 +0100
     2.3 @@ -745,7 +745,10 @@ found:
     2.4  		}
     2.5  		memcpy(tmp_ptr2, l2_ptr, 4096);
     2.6  		lseek(s->fd, l2_offset + (l2_sector << 12), SEEK_SET);
     2.7 -		write(s->fd, tmp_ptr2, 4096);
     2.8 +		if (write(s->fd, tmp_ptr2, 4096) != 4096) {
     2.9 +			free(tmp_ptr2);
    2.10 +			return -1;
    2.11 +		}
    2.12  		free(tmp_ptr2);
    2.13  	}
    2.14  	return cluster_offset;
    2.15 @@ -1252,8 +1255,8 @@ int qcow_create(const char *filename, ui
    2.16  				strncpy(backing_filename, backing_file,
    2.17  					sizeof(backing_filename));
    2.18  			} else {
    2.19 -				realpath(backing_file, backing_filename);
    2.20 -				if (stat(backing_filename, &st) != 0) {
    2.21 +				if (realpath(backing_file, backing_filename) == NULL ||
    2.22 +				    stat(backing_filename, &st) != 0) {
    2.23  					return -1;
    2.24  				}
    2.25  			}
     3.1 --- a/tools/blktap/drivers/block-vmdk.c	Thu May 24 14:05:58 2007 +0100
     3.2 +++ b/tools/blktap/drivers/block-vmdk.c	Thu May 24 14:07:40 2007 +0100
     3.3 @@ -283,8 +283,9 @@ static uint64_t get_cluster_offset(struc
     3.4          	if (!allocate)
     3.5              		return 0;
     3.6          	cluster_offset = lseek(prv->fd, 0, SEEK_END);
     3.7 -        	ftruncate(prv->fd, cluster_offset + 
     3.8 -			  (prv->cluster_sectors << 9));
     3.9 +        	if (ftruncate(prv->fd, cluster_offset + 
    3.10 +			      (prv->cluster_sectors << 9)))
    3.11 +			return 0;
    3.12          	cluster_offset >>= 9;
    3.13          	/* update L2 table */
    3.14          	tmp = cpu_to_le32(cluster_offset);