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>
This commit is contained in:
kfraser@localhost.localdomain committed 2007-05-24 14:07:40 +01:00
1 parent 1c77b7cb9f
commit ecc82ca3e6
3 files changed
+13 -6

No files matched your search

+4 -1
View File
@@ -678,7 +678,10 @@ int main(int argc, char *argv[])
__init_blkif();
snprintf(buf, sizeof(buf), "BLKTAPCTRL[%d]", getpid());
openlog(buf, LOG_CONS|LOG_ODELAY, LOG_DAEMON);
daemon(0,0);
if (daemon(0,0)) {
DPRINTF("daemon failed (%d)\n", errno);
goto open_failed;
}
print_drivers();
init_driver_list();
+6 -3
View File
@@ -745,7 +745,10 @@ found:
}
memcpy(tmp_ptr2, l2_ptr, 4096);
lseek(s->fd, l2_offset + (l2_sector << 12), SEEK_SET);
write(s->fd, tmp_ptr2, 4096);
if (write(s->fd, tmp_ptr2, 4096) != 4096) {
free(tmp_ptr2);
return -1;
}
free(tmp_ptr2);
}
return cluster_offset;
@@ -1252,8 +1255,8 @@ int qcow_create(const char *filename, uint64_t total_size,
strncpy(backing_filename, backing_file,
sizeof(backing_filename));
} else {
realpath(backing_file, backing_filename);
if (stat(backing_filename, &st) != 0) {
if (realpath(backing_file, backing_filename) == NULL ||
stat(backing_filename, &st) != 0) {
return -1;
}
}
+3 -2
View File
@@ -283,8 +283,9 @@ static uint64_t get_cluster_offset(struct tdvmdk_state *prv,
if (!allocate)
return 0;
cluster_offset = lseek(prv->fd, 0, SEEK_END);
ftruncate(prv->fd, cluster_offset +
(prv->cluster_sectors << 9));
if (ftruncate(prv->fd, cluster_offset +
(prv->cluster_sectors << 9)))
return 0;
cluster_offset >>= 9;
/* update L2 table */
tmp = cpu_to_le32(cluster_offset);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.