compile errors in blktap
PATCH 1/1 compile errors in blktap
When compiling the various blktap drivers with warnings cranked up, I get errors that return values are not checked.
The attached patch adds error checking to properly fix several error paths. It applies against xen-unstable.
Signed-off-by Charles Coffing <[email protected]>
tools/blktap/drivers/blktapctrl.c +4 -1
@@ -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 ();
tools/blktap/drivers/block-vmdk.c +3 -2
@@ -283,8 +283,9 @@ static uint64_t get_cluster_offset(strucif (!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);
tools/blktap/drivers/block-qcow.c +6 -3
@@ -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, uistrncpy (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 ; } }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel