ia64/xen-unstable

changeset 7535:76392609363f

BUG_ON() is a macro very very similar to assert(), and it's a really bad
idea in general to put statements with side-effects inside such a construct
(for example the BUG_ON() could be compiled away for non-debug builds).

The patch below fixes this for the drivers/xen tree.

I chose the general construct to store the respective return values in a
local var instead of an if (...) BUG(); because it looks like most of these
BUG_ON()'s need to be replaced by real error handling when going towards
production releases anyway, and then the local variable is going to be
needed anyway. (and besides the if construct tends to get unreable due to
the unlikely() etc).

Please apply.

Greetings,
Arjan van de Ven
author kaf24@firebug.cl.cam.ac.uk
date Thu Oct 27 17:09:01 2005 +0100 (2005-10-27)
parents e70ea9465b31
children 3843e518e092
files linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blkback/interface.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c linux-2.6-xen-sparse/drivers/xen/blktap/interface.c linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c linux-2.6-xen-sparse/drivers/xen/util.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Oct 27 10:53:02 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Thu Oct 27 17:09:01 2005 +0100
     1.3 @@ -191,12 +191,13 @@ static int increase_reservation(unsigned
     1.4  	rc = HYPERVISOR_memory_op(
     1.5  		XENMEM_increase_reservation, &reservation);
     1.6  	if (rc < nr_pages) {
     1.7 +		int ret;
     1.8  		/* We hit the Xen hard limit: reprobe. */
     1.9  		reservation.extent_start = mfn_list;
    1.10  		reservation.nr_extents   = rc;
    1.11 -		BUG_ON(HYPERVISOR_memory_op(
    1.12 -			XENMEM_decrease_reservation,
    1.13 -			&reservation) != rc);
    1.14 +		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
    1.15 +				&reservation);
    1.16 +		BUG_ON(ret != rc);
    1.17  		hard_limit = current_pages + rc - driver_pages;
    1.18  		goto out;
    1.19  	}
    1.20 @@ -213,11 +214,14 @@ static int increase_reservation(unsigned
    1.21  		xen_machphys_update(mfn_list[i], pfn);
    1.22              
    1.23  		/* Link back into the page tables if not highmem. */
    1.24 -		if (pfn < max_low_pfn)
    1.25 -			BUG_ON(HYPERVISOR_update_va_mapping(
    1.26 +		if (pfn < max_low_pfn) {
    1.27 +			int ret;
    1.28 +			ret = HYPERVISOR_update_va_mapping(
    1.29  				(unsigned long)__va(pfn << PAGE_SHIFT),
    1.30  				pfn_pte_ma(mfn_list[i], PAGE_KERNEL),
    1.31 -				0));
    1.32 +				0);
    1.33 +			BUG_ON(ret);
    1.34 +		}
    1.35  
    1.36  		/* Relinquish the page back to the allocator. */
    1.37  		ClearPageReserved(page);
    1.38 @@ -242,6 +246,7 @@ static int decrease_reservation(unsigned
    1.39  	struct page   *page;
    1.40  	void          *v;
    1.41  	int            need_sleep = 0;
    1.42 +	int ret;
    1.43  	struct xen_memory_reservation reservation = {
    1.44  		.address_bits = 0,
    1.45  		.extent_order = 0,
    1.46 @@ -268,8 +273,9 @@ static int decrease_reservation(unsigned
    1.47  		if (!PageHighMem(page)) {
    1.48  			v = phys_to_virt(pfn << PAGE_SHIFT);
    1.49  			scrub_pages(v, 1);
    1.50 -			BUG_ON(HYPERVISOR_update_va_mapping(
    1.51 -				(unsigned long)v, __pte_ma(0), 0));
    1.52 +			ret = HYPERVISOR_update_va_mapping(
    1.53 +				(unsigned long)v, __pte_ma(0), 0);
    1.54 +			BUG_ON(ret);
    1.55  		}
    1.56  #ifdef CONFIG_XEN_SCRUB_PAGES
    1.57  		else {
    1.58 @@ -295,8 +301,8 @@ static int decrease_reservation(unsigned
    1.59  
    1.60  	reservation.extent_start = mfn_list;
    1.61  	reservation.nr_extents   = nr_pages;
    1.62 -	BUG_ON(HYPERVISOR_memory_op(
    1.63 -		XENMEM_decrease_reservation, &reservation) != nr_pages);
    1.64 +	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    1.65 +	BUG_ON(ret != nr_pages);
    1.66  
    1.67  	current_pages -= nr_pages;
    1.68  	totalram_pages = current_pages;
    1.69 @@ -501,6 +507,7 @@ static int dealloc_pte_fn(
    1.70  	pte_t *pte, struct page *pte_page, unsigned long addr, void *data)
    1.71  {
    1.72  	unsigned long mfn = pte_mfn(*pte);
    1.73 +	int ret;
    1.74  	struct xen_memory_reservation reservation = {
    1.75  		.extent_start = &mfn,
    1.76  		.nr_extents   = 1,
    1.77 @@ -510,8 +517,8 @@ static int dealloc_pte_fn(
    1.78  	set_pte_at(&init_mm, addr, pte, __pte_ma(0));
    1.79  	phys_to_machine_mapping[__pa(addr) >> PAGE_SHIFT] =
    1.80  		INVALID_P2M_ENTRY;
    1.81 -	BUG_ON(HYPERVISOR_memory_op(
    1.82 -		XENMEM_decrease_reservation, &reservation) != 1);
    1.83 +	ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation);
    1.84 +	BUG_ON(ret != 1);
    1.85  	return 0;
    1.86  }
    1.87  
    1.88 @@ -519,6 +526,7 @@ struct page *balloon_alloc_empty_page_ra
    1.89  {
    1.90  	unsigned long vstart, flags;
    1.91  	unsigned int  order = get_order(nr_pages * PAGE_SIZE);
    1.92 +	int ret;
    1.93  
    1.94  	vstart = __get_free_pages(GFP_KERNEL, order);
    1.95  	if (vstart == 0)
    1.96 @@ -527,8 +535,9 @@ struct page *balloon_alloc_empty_page_ra
    1.97  	scrub_pages(vstart, 1 << order);
    1.98  
    1.99  	balloon_lock(flags);
   1.100 -	BUG_ON(generic_page_range(
   1.101 -		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL));
   1.102 +	ret = generic_page_range(
   1.103 +		&init_mm, vstart, PAGE_SIZE << order, dealloc_pte_fn, NULL);
   1.104 +	BUG_ON(ret);
   1.105  	current_pages -= 1UL << order;
   1.106  	balloon_unlock(flags);
   1.107  
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Oct 27 10:53:02 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Thu Oct 27 17:09:01 2005 +0100
     2.3 @@ -108,6 +108,7 @@ static void fast_flush_area(int idx, int
     2.4  	struct gnttab_unmap_grant_ref unmap[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     2.5  	unsigned int i, invcount = 0;
     2.6  	u16 handle;
     2.7 +	int ret;
     2.8  
     2.9  	for (i = 0; i < nr_pages; i++) {
    2.10  		handle = pending_handle(idx, i);
    2.11 @@ -120,8 +121,9 @@ static void fast_flush_area(int idx, int
    2.12  		invcount++;
    2.13  	}
    2.14  
    2.15 -	BUG_ON(HYPERVISOR_grant_table_op(
    2.16 -		GNTTABOP_unmap_grant_ref, unmap, invcount));
    2.17 +	ret = HYPERVISOR_grant_table_op(
    2.18 +		GNTTABOP_unmap_grant_ref, unmap, invcount);
    2.19 +	BUG_ON(ret);
    2.20  }
    2.21  
    2.22  
    2.23 @@ -338,6 +340,7 @@ static void dispatch_rw_block_io(blkif_t
    2.24  	struct bio *bio = NULL, *biolist[BLKIF_MAX_SEGMENTS_PER_REQUEST];
    2.25  	int nbio = 0;
    2.26  	request_queue_t *q;
    2.27 +	int ret;
    2.28  
    2.29  	/* Check that number of segments is sane. */
    2.30  	nseg = req->nr_segments;
    2.31 @@ -367,8 +370,8 @@ static void dispatch_rw_block_io(blkif_t
    2.32  			map[i].flags |= GNTMAP_readonly;
    2.33  	}
    2.34  
    2.35 -	BUG_ON(HYPERVISOR_grant_table_op(
    2.36 -		GNTTABOP_map_grant_ref, map, nseg));
    2.37 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, nseg);
    2.38 +	BUG_ON(ret);
    2.39  
    2.40  	for (i = 0; i < nseg; i++) {
    2.41  		if (unlikely(map[i].handle < 0)) {
    2.42 @@ -493,6 +496,7 @@ static int __init blkif_init(void)
    2.43  {
    2.44  	int i;
    2.45  	struct page *page;
    2.46 +	int ret;
    2.47  
    2.48  	blkif_interface_init();
    2.49  
    2.50 @@ -509,7 +513,8 @@ static int __init blkif_init(void)
    2.51  	spin_lock_init(&blkio_schedule_list_lock);
    2.52  	INIT_LIST_HEAD(&blkio_schedule_list);
    2.53  
    2.54 -	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
    2.55 +	ret = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
    2.56 +	BUG_ON(ret < 0);
    2.57  
    2.58  	blkif_xenbus_init();
    2.59  
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Oct 27 10:53:02 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Thu Oct 27 17:09:01 2005 +0100
     3.3 @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
     3.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
     3.5  {
     3.6  	struct gnttab_map_grant_ref op;
     3.7 +	int ret;
     3.8  
     3.9  	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
    3.10  	op.flags     = GNTMAP_host_map;
    3.11 @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
    3.12  	op.dom       = blkif->domid;
    3.13  
    3.14  	lock_vm_area(blkif->blk_ring_area);
    3.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
    3.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    3.17  	unlock_vm_area(blkif->blk_ring_area);
    3.18 +	BUG_ON(ret);
    3.19  
    3.20  	if (op.handle < 0) {
    3.21  		DPRINTK(" Grant table operation failure !\n");
    3.22 @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
    3.23  static void unmap_frontend_page(blkif_t *blkif)
    3.24  {
    3.25  	struct gnttab_unmap_grant_ref op;
    3.26 +	int ret;
    3.27  
    3.28  	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
    3.29  	op.handle       = blkif->shmem_handle;
    3.30  	op.dev_bus_addr = 0;
    3.31  
    3.32  	lock_vm_area(blkif->blk_ring_area);
    3.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    3.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    3.35  	unlock_vm_area(blkif->blk_ring_area);
    3.36 +	BUG_ON(ret);
    3.37  }
    3.38  
    3.39  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 27 10:53:02 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Oct 27 17:09:01 2005 +0100
     4.3 @@ -305,6 +305,7 @@ static irqreturn_t blkif_int(int irq, vo
     4.4  
     4.5  	for (i = info->ring.rsp_cons; i != rp; i++) {
     4.6  		unsigned long id;
     4.7 +		int ret;
     4.8  
     4.9  		bret = RING_GET_RESPONSE(&info->ring, i);
    4.10  		id   = bret->id;
    4.11 @@ -321,9 +322,10 @@ static irqreturn_t blkif_int(int irq, vo
    4.12  				DPRINTK("Bad return from blkdev data "
    4.13  					"request: %x\n", bret->status);
    4.14  
    4.15 -			BUG_ON(end_that_request_first(
    4.16 +			ret = end_that_request_first(
    4.17  				req, (bret->status == BLKIF_RSP_OKAY),
    4.18 -				req->hard_nr_sectors));
    4.19 +				req->hard_nr_sectors);
    4.20 +			BUG_ON(ret);
    4.21  			end_that_request_last(req);
    4.22  			break;
    4.23  		default:
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Oct 27 10:53:02 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Thu Oct 27 17:09:01 2005 +0100
     5.3 @@ -413,6 +413,7 @@ static void fast_flush_area(int idx, int
     5.4  	unsigned int i, op = 0;
     5.5  	struct grant_handle_pair *handle;
     5.6  	unsigned long ptep;
     5.7 +	int ret;
     5.8  
     5.9  	for ( i = 0; i < nr_pages; i++)
    5.10  	{
    5.11 @@ -440,8 +441,8 @@ static void fast_flush_area(int idx, int
    5.12  		BLKTAP_INVALIDATE_HANDLE(handle);
    5.13  	}
    5.14  
    5.15 -	BUG_ON(HYPERVISOR_grant_table_op(
    5.16 -		GNTTABOP_unmap_grant_ref, unmap, op));
    5.17 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap, op);
    5.18 +	BUG_ON(ret);
    5.19  
    5.20  	if (blktap_vma != NULL)
    5.21  		zap_page_range(blktap_vma, 
    5.22 @@ -673,6 +674,7 @@ static void dispatch_rw_block_io(blkif_t
    5.23  	struct gnttab_map_grant_ref map[BLKIF_MAX_SEGMENTS_PER_REQUEST*2];
    5.24  	int op, ret;
    5.25  	unsigned int nseg;
    5.26 +	int retval;
    5.27  
    5.28  	/* Check that number of segments is sane. */
    5.29  	nseg = req->nr_segments;
    5.30 @@ -740,8 +742,8 @@ static void dispatch_rw_block_io(blkif_t
    5.31  		op++;
    5.32  	}
    5.33  
    5.34 -	BUG_ON(HYPERVISOR_grant_table_op(
    5.35 -		GNTTABOP_map_grant_ref, map, op));
    5.36 +	retval = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map, op);
    5.37 +	BUG_ON(retval);
    5.38  
    5.39  	op = 0;
    5.40  	for (i = 0; i < (req->nr_segments*2); i += 2) {
    5.41 @@ -877,7 +879,8 @@ static int __init blkif_init(void)
    5.42  	spin_lock_init(&blkio_schedule_list_lock);
    5.43  	INIT_LIST_HEAD(&blkio_schedule_list);
    5.44  
    5.45 -	BUG_ON(kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES) < 0);
    5.46 +	i = kernel_thread(blkio_schedule, 0, CLONE_FS | CLONE_FILES);
    5.47 +	BUG_ON(i<0);
    5.48  
    5.49  	blkif_xenbus_init();
    5.50  
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Thu Oct 27 10:53:02 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Thu Oct 27 17:09:01 2005 +0100
     6.3 @@ -31,6 +31,7 @@ blkif_t *alloc_blkif(domid_t domid)
     6.4  static int map_frontend_page(blkif_t *blkif, unsigned long shared_page)
     6.5  {
     6.6  	struct gnttab_map_grant_ref op;
     6.7 +	int ret;
     6.8  
     6.9  	op.host_addr = (unsigned long)blkif->blk_ring_area->addr;
    6.10  	op.flags     = GNTMAP_host_map;
    6.11 @@ -38,8 +39,9 @@ static int map_frontend_page(blkif_t *bl
    6.12  	op.dom       = blkif->domid;
    6.13  
    6.14  	lock_vm_area(blkif->blk_ring_area);
    6.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
    6.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    6.17  	unlock_vm_area(blkif->blk_ring_area);
    6.18 +	BUG_ON(ret);
    6.19  
    6.20  	if (op.handle < 0) {
    6.21  		DPRINTK(" Grant table operation failure !\n");
    6.22 @@ -55,14 +57,16 @@ static int map_frontend_page(blkif_t *bl
    6.23  static void unmap_frontend_page(blkif_t *blkif)
    6.24  {
    6.25  	struct gnttab_unmap_grant_ref op;
    6.26 +	int ret;
    6.27  
    6.28  	op.host_addr    = (unsigned long)blkif->blk_ring_area->addr;
    6.29  	op.handle       = blkif->shmem_handle;
    6.30  	op.dev_bus_addr = 0;
    6.31  
    6.32  	lock_vm_area(blkif->blk_ring_area);
    6.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    6.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    6.35  	unlock_vm_area(blkif->blk_ring_area);
    6.36 +	BUG_ON(ret);
    6.37  }
    6.38  
    6.39  int blkif_map(blkif_t *blkif, unsigned long shared_page, unsigned int evtchn)
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu Oct 27 10:53:02 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/evtchn/evtchn.c	Thu Oct 27 17:09:01 2005 +0100
     7.3 @@ -282,6 +282,7 @@ static int evtchn_ioctl(struct inode *in
     7.4  
     7.5  	case IOCTL_EVTCHN_UNBIND: {
     7.6  		struct ioctl_evtchn_unbind unbind;
     7.7 +		int ret;
     7.8  
     7.9  		rc = -EFAULT;
    7.10  		if (copy_from_user(&unbind, (void *)arg, sizeof(unbind)))
    7.11 @@ -306,7 +307,8 @@ static int evtchn_ioctl(struct inode *in
    7.12  
    7.13  		op.cmd = EVTCHNOP_close;
    7.14  		op.u.close.port = unbind.port;
    7.15 -		BUG_ON(HYPERVISOR_event_channel_op(&op));
    7.16 +		ret = HYPERVISOR_event_channel_op(&op);
    7.17 +		BUG_ON(ret);
    7.18  
    7.19  		rc = 0;
    7.20  		break;
    7.21 @@ -399,6 +401,7 @@ static int evtchn_release(struct inode *
    7.22  
    7.23  	for (i = 0; i < NR_EVENT_CHANNELS; i++)
    7.24  	{
    7.25 +		int ret;
    7.26  		if (port_user[i] != u)
    7.27  			continue;
    7.28  
    7.29 @@ -407,7 +410,8 @@ static int evtchn_release(struct inode *
    7.30  
    7.31  		op.cmd = EVTCHNOP_close;
    7.32  		op.u.close.port = i;
    7.33 -		BUG_ON(HYPERVISOR_event_channel_op(&op));
    7.34 +		ret = HYPERVISOR_event_channel_op(&op);
    7.35 +		BUG_ON(ret);
    7.36  	}
    7.37  
    7.38  	spin_unlock_irq(&port_user_lock);
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Oct 27 10:53:02 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Oct 27 17:09:01 2005 +0100
     8.3 @@ -115,6 +115,7 @@ static int map_frontend_pages(
     8.4  	netif_t *netif, grant_ref_t tx_ring_ref, grant_ref_t rx_ring_ref)
     8.5  {
     8.6  	struct gnttab_map_grant_ref op;
     8.7 +	int ret;
     8.8  
     8.9  	op.host_addr = (unsigned long)netif->comms_area->addr;
    8.10  	op.flags     = GNTMAP_host_map;
    8.11 @@ -122,8 +123,9 @@ static int map_frontend_pages(
    8.12  	op.dom       = netif->domid;
    8.13      
    8.14  	lock_vm_area(netif->comms_area);
    8.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
    8.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    8.17  	unlock_vm_area(netif->comms_area);
    8.18 +	BUG_ON(ret);
    8.19  
    8.20  	if (op.handle < 0) { 
    8.21  		DPRINTK(" Gnttab failure mapping tx_ring_ref!\n");
    8.22 @@ -139,8 +141,9 @@ static int map_frontend_pages(
    8.23  	op.dom       = netif->domid;
    8.24  
    8.25  	lock_vm_area(netif->comms_area);
    8.26 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
    8.27 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    8.28  	unlock_vm_area(netif->comms_area);
    8.29 +	BUG_ON(ret);
    8.30  
    8.31  	if (op.handle < 0) { 
    8.32  		DPRINTK(" Gnttab failure mapping rx_ring_ref!\n");
    8.33 @@ -156,22 +159,25 @@ static int map_frontend_pages(
    8.34  static void unmap_frontend_pages(netif_t *netif)
    8.35  {
    8.36  	struct gnttab_unmap_grant_ref op;
    8.37 +	int ret;
    8.38  
    8.39  	op.host_addr    = (unsigned long)netif->comms_area->addr;
    8.40  	op.handle       = netif->tx_shmem_handle;
    8.41  	op.dev_bus_addr = 0;
    8.42  
    8.43  	lock_vm_area(netif->comms_area);
    8.44 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    8.45 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    8.46  	unlock_vm_area(netif->comms_area);
    8.47 +	BUG_ON(ret);
    8.48  
    8.49  	op.host_addr    = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
    8.50  	op.handle       = netif->rx_shmem_handle;
    8.51  	op.dev_bus_addr = 0;
    8.52  
    8.53  	lock_vm_area(netif->comms_area);
    8.54 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    8.55 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    8.56  	unlock_vm_area(netif->comms_area);
    8.57 +	BUG_ON(ret);
    8.58  }
    8.59  
    8.60  int netif_map(netif_t *netif, unsigned long tx_ring_ref,
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Oct 27 10:53:02 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Oct 27 17:09:01 2005 +0100
     9.3 @@ -112,9 +112,12 @@ static void free_mfn(unsigned long mfn)
     9.4  	spin_lock_irqsave(&mfn_lock, flags);
     9.5  	if ( alloc_index != MAX_MFN_ALLOC )
     9.6  		mfn_list[alloc_index++] = mfn;
     9.7 -	else
     9.8 -		BUG_ON(HYPERVISOR_memory_op(XENMEM_decrease_reservation,
     9.9 -					    &reservation) != 1);
    9.10 +	else {
    9.11 +		int ret;
    9.12 +		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
    9.13 +					    &reservation);
    9.14 +		BUG_ON(ret != 1);
    9.15 +	}
    9.16  	spin_unlock_irqrestore(&mfn_lock, flags);
    9.17  }
    9.18  #endif
    9.19 @@ -159,13 +162,15 @@ int netif_be_start_xmit(struct sk_buff *
    9.20  	 */
    9.21  	if (skb_shared(skb) || skb_cloned(skb) || !is_xen_skb(skb)) {
    9.22  		int hlen = skb->data - skb->head;
    9.23 +		int ret;
    9.24  		struct sk_buff *nskb = dev_alloc_skb(hlen + skb->len);
    9.25  		if ( unlikely(nskb == NULL) )
    9.26  			goto drop;
    9.27  		skb_reserve(nskb, hlen);
    9.28  		__skb_put(nskb, skb->len);
    9.29 -		BUG_ON(skb_copy_bits(skb, -hlen, nskb->data - hlen,
    9.30 -				     skb->len + hlen));
    9.31 +		ret = skb_copy_bits(skb, -hlen, nskb->data - hlen,
    9.32 +				     skb->len + hlen);
    9.33 +		BUG_ON(ret);
    9.34  		nskb->dev = skb->dev;
    9.35  		nskb->proto_csum_valid = skb->proto_csum_valid;
    9.36  		dev_kfree_skb(skb);
    9.37 @@ -218,6 +223,7 @@ static void net_rx_action(unsigned long 
    9.38  	struct sk_buff *skb;
    9.39  	u16 notify_list[NETIF_RX_RING_SIZE];
    9.40  	int notify_nr = 0;
    9.41 +	int ret;
    9.42  
    9.43  	skb_queue_head_init(&rxq);
    9.44  
    9.45 @@ -279,7 +285,8 @@ static void net_rx_action(unsigned long 
    9.46  	mcl++;
    9.47  
    9.48  	mcl[-2].args[MULTI_UVMFLAGS_INDEX] = UVMF_TLB_FLUSH|UVMF_ALL;
    9.49 -	BUG_ON(HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl) != 0);
    9.50 +	ret = HYPERVISOR_multicall(rx_mcl, mcl - rx_mcl);
    9.51 +	BUG_ON(ret != 0);
    9.52  
    9.53  	mcl = rx_mcl;
    9.54  	if( HYPERVISOR_grant_table_op(GNTTABOP_transfer, grant_rx_op, 
    9.55 @@ -421,6 +428,7 @@ inline static void net_tx_action_dealloc
    9.56  	u16 pending_idx;
    9.57  	PEND_RING_IDX dc, dp;
    9.58  	netif_t *netif;
    9.59 +	int ret;
    9.60  
    9.61  	dc = dealloc_cons;
    9.62  	dp = dealloc_prod;
    9.63 @@ -436,8 +444,9 @@ inline static void net_tx_action_dealloc
    9.64  		gop->handle       = grant_tx_ref[pending_idx];
    9.65  		gop++;
    9.66  	}
    9.67 -	BUG_ON(HYPERVISOR_grant_table_op(
    9.68 -		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
    9.69 +	ret = HYPERVISOR_grant_table_op(
    9.70 +		GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops);
    9.71 +	BUG_ON(ret);
    9.72  
    9.73  	while (dealloc_cons != dp) {
    9.74  		pending_idx = dealloc_ring[MASK_PEND_IDX(dealloc_cons++)];
    9.75 @@ -477,6 +486,7 @@ static void net_tx_action(unsigned long 
    9.76  	NETIF_RING_IDX i;
    9.77  	gnttab_map_grant_ref_t *mop;
    9.78  	unsigned int data_len;
    9.79 +	int ret;
    9.80  
    9.81  	if (dealloc_cons != dealloc_prod)
    9.82  		net_tx_action_dealloc();
    9.83 @@ -599,8 +609,9 @@ static void net_tx_action(unsigned long 
    9.84  	if (mop == tx_map_ops)
    9.85  		return;
    9.86  
    9.87 -	BUG_ON(HYPERVISOR_grant_table_op(
    9.88 -		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops));
    9.89 +	ret = HYPERVISOR_grant_table_op(
    9.90 +		GNTTABOP_map_grant_ref, tx_map_ops, mop - tx_map_ops);
    9.91 +	BUG_ON(ret);
    9.92  
    9.93  	mop = tx_map_ops;
    9.94  	while ((skb = __skb_dequeue(&tx_queue)) != NULL) {
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Thu Oct 27 10:53:02 2005 +0100
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Thu Oct 27 17:09:01 2005 +0100
    10.3 @@ -78,6 +78,7 @@ tpmif_find(domid_t domid, long int insta
    10.4  static int
    10.5  map_frontend_page(tpmif_t *tpmif, unsigned long shared_page)
    10.6  {
    10.7 +	int ret;
    10.8  	struct gnttab_map_grant_ref op = {
    10.9  		.host_addr = (unsigned long)tpmif->tx_area->addr,
   10.10  		.flags = GNTMAP_host_map,
   10.11 @@ -86,8 +87,9 @@ map_frontend_page(tpmif_t *tpmif, unsign
   10.12  	};
   10.13  
   10.14  	lock_vm_area(tpmif->tx_area);
   10.15 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1));
   10.16 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
   10.17  	unlock_vm_area(tpmif->tx_area);
   10.18 +	BUG_ON(ret);
   10.19  
   10.20  	if (op.handle < 0) {
   10.21  		DPRINTK(" Grant table operation failure !\n");
   10.22 @@ -104,14 +106,16 @@ static void
   10.23  unmap_frontend_page(tpmif_t *tpmif)
   10.24  {
   10.25  	struct gnttab_unmap_grant_ref op;
   10.26 +	int ret;
   10.27  
   10.28  	op.host_addr    = (unsigned long)tpmif->tx_area->addr;
   10.29  	op.handle       = tpmif->shmem_handle;
   10.30  	op.dev_bus_addr = 0;
   10.31  
   10.32  	lock_vm_area(tpmif->tx_area);
   10.33 -	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
   10.34 +	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
   10.35  	unlock_vm_area(tpmif->tx_area);
   10.36 +	BUG_ON(ret);
   10.37  }
   10.38  
   10.39  int
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/util.c	Thu Oct 27 10:53:02 2005 +0100
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/util.c	Thu Oct 27 17:09:01 2005 +0100
    11.3 @@ -34,7 +34,9 @@ struct vm_struct *alloc_vm_area(unsigned
    11.4  
    11.5  void free_vm_area(struct vm_struct *area)
    11.6  {
    11.7 -	BUG_ON(remove_vm_area(area->addr) != area);
    11.8 +	struct vm_struct *ret;
    11.9 +	ret = remove_vm_area(area->addr);
   11.10 +	BUG_ON(ret != area);
   11.11  	kfree(area);
   11.12  }
   11.13  
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 27 10:53:02 2005 +0100
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Thu Oct 27 17:09:01 2005 +0100
    12.3 @@ -737,6 +737,7 @@ static int __init xenbus_probe_init(void
    12.4  
    12.5  		unsigned long page;
    12.6  		evtchn_op_t op = { 0 };
    12.7 +		int ret;
    12.8  
    12.9  
   12.10  		/* Allocate page. */
   12.11 @@ -757,7 +758,8 @@ static int __init xenbus_probe_init(void
   12.12  		op.u.alloc_unbound.dom        = DOMID_SELF;
   12.13  		op.u.alloc_unbound.remote_dom = 0; 
   12.14  
   12.15 -		BUG_ON(HYPERVISOR_event_channel_op(&op)); 
   12.16 +		ret = HYPERVISOR_event_channel_op(&op);
   12.17 +		BUG_ON(ret); 
   12.18  		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
   12.19  
   12.20  		/* And finally publish the above info in /proc/xen */