direct-io.hg

changeset 7765:fcb7e5616102

Remove unnecessary NULL checks before freeing memory blocks.
The following functions check for NULL internally:
free, kfree, xfree, free_xenheap_page[s]

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Nov 11 12:55:47 2005 +0100 (2005-11-11)
parents 41c8a2ea07c0
children cc5450d52e49
files linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c linux-2.6-xen-sparse/drivers/xen/netback/loopback.c linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c tools/blktap/blkif.c tools/blktap/parallax/blockstore.c tools/blktap/parallax/blockstored.c tools/blktap/parallax/requests-async.c tools/blktap/xenbus.c tools/console/daemon/io.c tools/ioemu/hw/magic-load.c tools/ioemu/vnc.c tools/libxc/xc_ia64_stubs.c tools/libxc/xc_linux_build.c tools/libxc/xc_vmx_build.c tools/python/xen/lowlevel/xs/xs.c tools/vtpm_manager/manager/securestorage.c tools/vtpm_manager/util/bsg.c tools/xenstat/libxenstat/src/xenstat.c tools/xenstore/xenstored_core.c xen/acm/acm_chinesewall_hooks.c xen/acm/acm_simple_type_enforcement_hooks.c xen/arch/ia64/xen/grant_table.c xen/arch/x86/mm.c xen/arch/x86/mtrr/generic.c xen/arch/x86/vmx_vmcs.c xen/common/event_channel.c xen/common/grant_table.c xen/common/page_alloc.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Nov 11 11:16:46 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Fri Nov 11 12:55:47 2005 +0100
     1.3 @@ -97,9 +97,7 @@ static inline unsigned char *
     1.4  transmission_set_buffer(struct transmission *t,
     1.5                          unsigned char *buffer, unsigned int len)
     1.6  {
     1.7 -	if (NULL != t->request) {
     1.8 -		kfree(t->request);
     1.9 -	}
    1.10 +	kfree(t->request);
    1.11  	t->request = kmalloc(len, GFP_KERNEL);
    1.12  	if (t->request) {
    1.13  		memcpy(t->request,
    1.14 @@ -113,12 +111,8 @@ transmission_set_buffer(struct transmiss
    1.15  static inline void
    1.16  transmission_free(struct transmission *t)
    1.17  {
    1.18 -	if (t->request) {
    1.19 -		kfree(t->request);
    1.20 -	}
    1.21 -	if (t->rcv_buffer) {
    1.22 -		kfree(t->rcv_buffer);
    1.23 -	}
    1.24 +	kfree(t->request);
    1.25 +	kfree(t->rcv_buffer);
    1.26  	kfree(t);
    1.27  }
    1.28  
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Nov 11 11:16:46 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c	Fri Nov 11 12:55:47 2005 +0100
     2.3 @@ -48,8 +48,7 @@ static int blkback_remove(struct xenbus_
     2.4  	unregister_xenbus_watch(&be->backend_watch);
     2.5  	if (be->blkif)
     2.6  		blkif_put(be->blkif);
     2.7 -	if (be->frontpath)
     2.8 -		kfree(be->frontpath);
     2.9 +	kfree(be->frontpath);
    2.10  	kfree(be);
    2.11  	return 0;
    2.12  }
    2.13 @@ -274,8 +273,7 @@ static int blkback_probe(struct xenbus_d
    2.14   free_be:
    2.15  	if (be->backend_watch.node)
    2.16  		unregister_xenbus_watch(&be->backend_watch);
    2.17 -	if (frontend)
    2.18 -		kfree(frontend);
    2.19 +	kfree(frontend);
    2.20  	kfree(be);
    2.21  	return err;
    2.22  }
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Nov 11 11:16:46 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Nov 11 12:55:47 2005 +0100
     3.3 @@ -607,8 +607,7 @@ again:
     3.4   destroy_blkring:
     3.5  	blkif_free(info);
     3.6   out:
     3.7 -	if (backend)
     3.8 -		kfree(backend);
     3.9 +	kfree(backend);
    3.10  	return err;
    3.11  }
    3.12  
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Fri Nov 11 11:16:46 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c	Fri Nov 11 12:55:47 2005 +0100
     4.3 @@ -52,8 +52,7 @@ static int blkback_remove(struct xenbus_
     4.4  	unregister_xenbus_watch(&be->backend_watch);
     4.5  	if (be->blkif)
     4.6  		blkif_put(be->blkif);
     4.7 -	if (be->frontpath)
     4.8 -		kfree(be->frontpath);
     4.9 +	kfree(be->frontpath);
    4.10  	kfree(be);
    4.11  	return 0;
    4.12  }
    4.13 @@ -201,8 +200,7 @@ static int blkback_probe(struct xenbus_d
    4.14   free_be:
    4.15  	if (be->backend_watch.node)
    4.16  		unregister_xenbus_watch(&be->backend_watch);
    4.17 -	if (frontend)
    4.18 -		kfree(frontend);
    4.19 +	kfree(frontend);
    4.20  	kfree(be);
    4.21  	return err;
    4.22  }
     5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Fri Nov 11 11:16:46 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c	Fri Nov 11 12:55:47 2005 +0100
     5.3 @@ -160,10 +160,8 @@ static int __init make_loopback(int i)
     5.4  	return 0;
     5.5  
     5.6   fail:
     5.7 -	if (dev1 != NULL)
     5.8 -		kfree(dev1);
     5.9 -	if (dev2 != NULL)
    5.10 -		kfree(dev2);
    5.11 +	kfree(dev1);
    5.12 +	kfree(dev2);
    5.13  	return err;
    5.14  }
    5.15  
     6.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Nov 11 11:16:46 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Fri Nov 11 12:55:47 2005 +0100
     6.3 @@ -46,8 +46,7 @@ static int netback_remove(struct xenbus_
     6.4  	unregister_xenbus_watch(&be->backend_watch);
     6.5  	if (be->netif)
     6.6  		netif_disconnect(be->netif);
     6.7 -	if (be->frontpath)
     6.8 -		kfree(be->frontpath);
     6.9 +	kfree(be->frontpath);
    6.10  	kfree(be);
    6.11  	return 0;
    6.12  }
    6.13 @@ -253,8 +252,7 @@ static int netback_probe(struct xenbus_d
    6.14   free_be:
    6.15  	if (be->backend_watch.node)
    6.16  		unregister_xenbus_watch(&be->backend_watch);
    6.17 -	if (frontend)
    6.18 -		kfree(frontend);
    6.19 +	kfree(frontend);
    6.20  	kfree(be);
    6.21  	return err;
    6.22  }
     7.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Nov 11 11:16:46 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Nov 11 12:55:47 2005 +0100
     7.3 @@ -917,7 +917,7 @@ static int create_netdev(int handle, str
     7.4  	np->netdev = netdev;
     7.5  
     7.6   exit:
     7.7 -	if ((err != 0) && (netdev != NULL))
     7.8 +	if (err != 0)
     7.9  		kfree(netdev);
    7.10  	else if (val != NULL)
    7.11  		*val = netdev;
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Fri Nov 11 11:16:46 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c	Fri Nov 11 12:55:47 2005 +0100
     8.3 @@ -167,9 +167,7 @@ static void inline
     8.4  packet_free(struct packet *pak)
     8.5  {
     8.6  	del_singleshot_timer_sync(&pak->processing_timer);
     8.7 -	if (pak->data_buffer) {
     8.8 -		kfree(pak->data_buffer);
     8.9 -	}
    8.10 +	kfree(pak->data_buffer);
    8.11  	/*
    8.12  	 * cannot do tpmif_put(pak->tpmif); bad things happen
    8.13  	 * on the last tpmif_put()
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Nov 11 11:16:46 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c	Fri Nov 11 12:55:47 2005 +0100
     9.3 @@ -41,19 +41,16 @@ static int tpmback_remove(struct xenbus_
     9.4  {
     9.5  	struct backend_info *be = dev->data;
     9.6  
     9.7 -	if (be->watch.node) {
     9.8 +	if (be->watch.node)
     9.9  		unregister_xenbus_watch(&be->watch);
    9.10 -	}
    9.11  	unregister_xenbus_watch(&be->backend_watch);
    9.12  
    9.13  	tpmif_vtpm_close(be->instance);
    9.14  
    9.15 -	if (be->tpmif) {
    9.16 +	if (be->tpmif)
    9.17  		tpmif_put(be->tpmif);
    9.18 -	}
    9.19  
    9.20 -	if (be->frontpath)
    9.21 -		kfree(be->frontpath);
    9.22 +	kfree(be->frontpath);
    9.23  	kfree(be);
    9.24  	return 0;
    9.25  }
    9.26 @@ -258,8 +255,7 @@ static int tpmback_probe(struct xenbus_d
    9.27  free_be:
    9.28  	if (be->backend_watch.node)
    9.29  		unregister_xenbus_watch(&be->backend_watch);
    9.30 -	if (frontend)
    9.31 -		kfree(frontend);
    9.32 +	kfree(frontend);
    9.33  	kfree(be);
    9.34  	return err;
    9.35  }
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Fri Nov 11 11:16:46 2005 +0100
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c	Fri Nov 11 12:55:47 2005 +0100
    10.3 @@ -387,8 +387,7 @@ abort_transaction:
    10.4  destroy_tpmring:
    10.5  	destroy_tpmring(info, &my_private);
    10.6  out:
    10.7 -	if (backend)
    10.8 -		kfree(backend);
    10.9 +	kfree(backend);
   10.10  	return err;
   10.11  }
   10.12  
    11.1 --- a/tools/blktap/blkif.c	Fri Nov 11 11:16:46 2005 +0100
    11.2 +++ b/tools/blktap/blkif.c	Fri Nov 11 12:55:47 2005 +0100
    11.3 @@ -108,8 +108,7 @@ void free_blkif(blkif_t *blkif)
    11.4          }
    11.5          pblkif = &curs->hash_next;
    11.6      }
    11.7 -    if (blkif != NULL)
    11.8 -        free(blkif);
    11.9 +    free(blkif);
   11.10  }
   11.11  
   11.12  void blkif_register_request_hook(blkif_t *blkif, char *name, 
    12.1 --- a/tools/blktap/parallax/blockstore.c	Fri Nov 11 11:16:46 2005 +0100
    12.2 +++ b/tools/blktap/parallax/blockstore.c	Fri Nov 11 12:55:47 2005 +0100
    12.3 @@ -604,8 +604,7 @@ void *readblock_indiv(int server, uint64
    12.4      return block;
    12.5  
    12.6      err:
    12.7 -    if (qe->block)
    12.8 -        free(qe->block);
    12.9 +    free(qe->block);
   12.10      free((void *)qe);
   12.11      return NULL;
   12.12  }
   12.13 @@ -1072,7 +1071,7 @@ uint64_t allocblock_hint(void *block, ui
   12.14   *
   12.15   *   @return: pointer to new block, NULL on error
   12.16   */
   12.17 -void *newblock() {
   12.18 +void *newblock(void) {
   12.19      void *block = malloc(BLOCK_SIZE);
   12.20      if (block == NULL) {
   12.21          perror("newblock");
   12.22 @@ -1089,7 +1088,6 @@ void *newblock() {
   12.23   *   @block: block to be freed
   12.24   */
   12.25  void freeblock(void *block) {
   12.26 -    if (block != NULL)
   12.27          free(block);
   12.28  }
   12.29  
    13.1 --- a/tools/blktap/parallax/blockstored.c	Fri Nov 11 11:16:46 2005 +0100
    13.2 +++ b/tools/blktap/parallax/blockstored.c	Fri Nov 11 12:55:47 2005 +0100
    13.3 @@ -232,7 +232,7 @@ uint64_t allocblock(void *block) {
    13.4   *
    13.5   *   @return: pointer to new block, NULL on error
    13.6   */
    13.7 -void *newblock() {
    13.8 +void *newblock(void) {
    13.9      void *block = malloc(BLOCK_SIZE);
   13.10      if (block == NULL) {
   13.11          perror("newblock");
   13.12 @@ -249,7 +249,6 @@ void *newblock() {
   13.13   *   @block: block to be freed
   13.14   */
   13.15  void freeblock(void *block) {
   13.16 -    if (block != NULL)
   13.17          free(block);
   13.18  }
   13.19  
    14.1 --- a/tools/blktap/parallax/requests-async.c	Fri Nov 11 11:16:46 2005 +0100
    14.2 +++ b/tools/blktap/parallax/requests-async.c	Fri Nov 11 12:55:47 2005 +0100
    14.3 @@ -715,7 +715,7 @@ static void write_cb(struct io_ret r, vo
    14.4          r.u.i  = -1;
    14.5          /* free any saved node vals. */
    14.6          for (i=0; i<3; i++)
    14.7 -            if (req->radix[i] != 0) free(req->radix[i]);
    14.8 +            free(req->radix[i]);
    14.9          free(req);
   14.10          cb(r, req_param);
   14.11      }
    15.1 --- a/tools/blktap/xenbus.c	Fri Nov 11 11:16:46 2005 +0100
    15.2 +++ b/tools/blktap/xenbus.c	Fri Nov 11 12:55:47 2005 +0100
    15.3 @@ -339,10 +339,8 @@ static int backend_remove(struct xs_hand
    15.4      /* Free everything else. */
    15.5      if (be->blkif)
    15.6          free_blkif(be->blkif);
    15.7 -    if (be->frontpath)
    15.8 -        free(be->frontpath);
    15.9 -    if (be->backpath)
   15.10 -        free(be->backpath);
   15.11 +    free(be->frontpath);
   15.12 +    free(be->backpath);
   15.13      free(be);
   15.14      return 0;
   15.15  }
   15.16 @@ -406,8 +404,7 @@ static void frontend_changed(struct xs_h
   15.17      return;
   15.18  
   15.19   fail:
   15.20 -    if (fepath)
   15.21 -        free(fepath);
   15.22 +    free(fepath);
   15.23  }
   15.24  
   15.25  
   15.26 @@ -460,9 +457,7 @@ static void backend_changed(struct xs_ha
   15.27      }
   15.28  
   15.29   fail:
   15.30 -    if (path)
   15.31 -        free(path);
   15.32 -
   15.33 +    free(path);
   15.34  }
   15.35  
   15.36  static void blkback_probe(struct xs_handle *h, struct xenbus_watch *w, 
   15.37 @@ -537,12 +532,10 @@ static void blkback_probe(struct xs_hand
   15.38  	return;
   15.39  
   15.40   free_be:
   15.41 -	if ((be) && (be->backend_watch.node))
   15.42 +	if (be && (be->backend_watch.node))
   15.43              unregister_xenbus_watch(h, &be->backend_watch);
   15.44 -	if (frontend)
   15.45 -            free(frontend);
   15.46 -        if (bepath)
   15.47 -            free(bepath);
   15.48 +        free(frontend);
   15.49 +        free(bepath);
   15.50  	free(be);
   15.51  	return;
   15.52  }
    16.1 --- a/tools/console/daemon/io.c	Fri Nov 11 11:16:46 2005 +0100
    16.2 +++ b/tools/console/daemon/io.c	Fri Nov 11 12:55:47 2005 +0100
    16.3 @@ -344,8 +344,7 @@ static struct domain *create_domain(int 
    16.4  
    16.5  	return dom;
    16.6   out:
    16.7 -	if (dom->conspath)
    16.8 -		free(dom->conspath);
    16.9 +	free(dom->conspath);
   16.10  	free(dom);
   16.11  	return NULL;
   16.12  }
   16.13 @@ -380,20 +379,16 @@ static void cleanup_domain(struct domain
   16.14  	if (!buffer_empty(&d->buffer))
   16.15  		return;
   16.16  
   16.17 -	if (d->buffer.data) {
   16.18 -		free(d->buffer.data);
   16.19 -		d->buffer.data = NULL;
   16.20 -	}
   16.21 -
   16.22  	if (d->tty_fd != -1) {
   16.23  		close(d->tty_fd);
   16.24  		d->tty_fd = -1;
   16.25  	}
   16.26  
   16.27 -	if (d->conspath) {
   16.28 -		free(d->conspath);
   16.29 -		d->conspath = NULL;
   16.30 -	}
   16.31 +	free(d->buffer.data);
   16.32 +	d->buffer.data = NULL;
   16.33 +
   16.34 +	free(d->conspath);
   16.35 +	d->conspath = NULL;
   16.36  
   16.37  	remove_domain(d);
   16.38  }
    17.1 --- a/tools/ioemu/hw/magic-load.c	Fri Nov 11 11:16:46 2005 +0100
    17.2 +++ b/tools/ioemu/hw/magic-load.c	Fri Nov 11 12:55:47 2005 +0100
    17.3 @@ -196,10 +196,8 @@ static void load_symbols(struct elfhdr *
    17.4  	goto error_freesyms;
    17.5  
    17.6      /* Commit */
    17.7 -    if (disas_symtab)
    17.8 -	qemu_free(disas_symtab); /* XXX Merge with old symbols? */
    17.9 -    if (disas_strtab)
   17.10 -	qemu_free(disas_strtab);
   17.11 +    qemu_free(disas_symtab); /* XXX Merge with old symbols? */
   17.12 +    qemu_free(disas_strtab);
   17.13      disas_symtab = syms;
   17.14      disas_num_syms = nsyms;
   17.15      disas_strtab = str;
    18.1 --- a/tools/ioemu/vnc.c	Fri Nov 11 11:16:46 2005 +0100
    18.2 +++ b/tools/ioemu/vnc.c	Fri Nov 11 12:55:47 2005 +0100
    18.3 @@ -187,8 +187,7 @@ static void mouse_find_bounding_box_of_d
    18.4  
    18.5  static void start_mouse_calibration() {
    18.6  	int size = screen->height*screen->paddedWidthInBytes;
    18.7 -	if(mouse_magic->calibration)
    18.8 -		free(mouse_magic->calibration);
    18.9 +	free(mouse_magic->calibration);
   18.10  	mouse_magic->calibration = malloc(size);
   18.11  	memcpy(mouse_magic->calibration, screen->frameBuffer, size);
   18.12  	calibration_step=0;
   18.13 @@ -198,8 +197,7 @@ static void start_mouse_calibration() {
   18.14  }
   18.15  
   18.16  static void stop_mouse_calibration() {
   18.17 -	if(mouse_magic->calibration)
   18.18 -		free(mouse_magic->calibration);
   18.19 +	free(mouse_magic->calibration);
   18.20  	mouse_magic->calibration = 0;
   18.21  }
   18.22  
    19.1 --- a/tools/libxc/xc_ia64_stubs.c	Fri Nov 11 11:16:46 2005 +0100
    19.2 +++ b/tools/libxc/xc_ia64_stubs.c	Fri Nov 11 12:55:47 2005 +0100
    19.3 @@ -77,7 +77,7 @@ int xc_ia64_copy_to_domain_pages(int xc_
    19.4  {
    19.5      // N.B. gva should be page aligned
    19.6      
    19.7 -    unsigned long *page_array=NULL;
    19.8 +    unsigned long *page_array = NULL;
    19.9      int i;
   19.10  
   19.11      if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL ){
   19.12 @@ -99,8 +99,7 @@ int xc_ia64_copy_to_domain_pages(int xc_
   19.13      return 0;
   19.14      
   19.15  error_out:
   19.16 -    if (page_array)
   19.17 -        free(page_array);
   19.18 +    free(page_array);
   19.19      return -1;
   19.20  }
   19.21  
   19.22 @@ -657,8 +656,7 @@ int xc_vmx_build(int xc_handle,
   19.23          goto error_out;
   19.24      }
   19.25  
   19.26 -    if ( image != NULL )
   19.27 -        free(image);
   19.28 +    free(image);
   19.29  
   19.30      ctxt->flags = VGCF_VMX_GUEST;
   19.31      ctxt->regs.cr_iip = 0x80000000ffffffb0UL;
   19.32 @@ -675,9 +673,7 @@ int xc_vmx_build(int xc_handle,
   19.33      return rc;
   19.34  
   19.35   error_out:
   19.36 -    if ( image != NULL )
   19.37 -        free(image);
   19.38 -
   19.39 +    free(image);
   19.40      return -1;
   19.41  }
   19.42  
    20.1 --- a/tools/libxc/xc_linux_build.c	Fri Nov 11 11:16:46 2005 +0100
    20.2 +++ b/tools/libxc/xc_linux_build.c	Fri Nov 11 12:55:47 2005 +0100
    20.3 @@ -670,10 +670,8 @@ static int setup_guest(int xc_handle,
    20.4      return 0;
    20.5  
    20.6   error_out:
    20.7 -    if ( mmu != NULL )
    20.8 -        free(mmu);
    20.9 -    if ( page_array != NULL )
   20.10 -        free(page_array);
   20.11 +    free(mmu);
   20.12 +    free(page_array);
   20.13      return -1;
   20.14  }
   20.15  #endif
   20.16 @@ -768,8 +766,7 @@ int xc_linux_build(int xc_handle,
   20.17          close(initrd_fd);
   20.18      if ( initrd_gfd )
   20.19          gzclose(initrd_gfd);
   20.20 -    if ( image != NULL )
   20.21 -        free(image);
   20.22 +    free(image);
   20.23  
   20.24  #ifdef __ia64__
   20.25      /* based on new_thread in xen/arch/ia64/domain.c */
   20.26 @@ -858,9 +855,7 @@ int xc_linux_build(int xc_handle,
   20.27          gzclose(initrd_gfd);
   20.28      else if ( initrd_fd >= 0 )
   20.29          close(initrd_fd);
   20.30 -    if ( image != NULL )
   20.31 -        free(image);
   20.32 -
   20.33 +    free(image);
   20.34      return -1;
   20.35  }
   20.36  
    21.1 --- a/tools/libxc/xc_vmx_build.c	Fri Nov 11 11:16:46 2005 +0100
    21.2 +++ b/tools/libxc/xc_vmx_build.c	Fri Nov 11 12:55:47 2005 +0100
    21.3 @@ -565,10 +565,8 @@ static int setup_guest(int xc_handle,
    21.4      return 0;
    21.5  
    21.6   error_out:
    21.7 -    if ( mmu != NULL )
    21.8 -        free(mmu);
    21.9 -    if ( page_array != NULL )
   21.10 -        free(page_array);
   21.11 +    free(mmu);
   21.12 +    free(page_array);
   21.13      return -1;
   21.14  }
   21.15  
   21.16 @@ -663,8 +661,7 @@ int xc_vmx_build(int xc_handle,
   21.17          goto error_out;
   21.18      }
   21.19  
   21.20 -    if ( image != NULL )
   21.21 -        free(image);
   21.22 +    free(image);
   21.23  
   21.24      ctxt->flags = VGCF_VMX_GUEST;
   21.25      /* FPU is set up to default initial state. */
   21.26 @@ -710,9 +707,7 @@ int xc_vmx_build(int xc_handle,
   21.27      return rc;
   21.28  
   21.29   error_out:
   21.30 -    if ( image != NULL )
   21.31 -        free(image);
   21.32 -
   21.33 +    free(image);
   21.34      return -1;
   21.35  }
   21.36  
    22.1 --- a/tools/python/xen/lowlevel/xs/xs.c	Fri Nov 11 11:16:46 2005 +0100
    22.2 +++ b/tools/python/xen/lowlevel/xs/xs.c	Fri Nov 11 12:55:47 2005 +0100
    22.3 @@ -114,8 +114,7 @@ static PyObject *xspy_read(PyObject *sel
    22.4      }
    22.5      val = PyString_FromStringAndSize(xsval, xsval_n);
    22.6   exit:
    22.7 -    if (xsval)
    22.8 -        free(xsval);
    22.9 +    free(xsval);
   22.10      return val;
   22.11  }
   22.12  
   22.13 @@ -427,8 +426,7 @@ static PyObject *xspy_set_permissions(Py
   22.14      val = Py_None;
   22.15   exit:
   22.16      Py_XDECREF(tuple0);
   22.17 -    if (xsperms)
   22.18 -        free(xsperms);
   22.19 +    free(xsperms);
   22.20      return val;
   22.21  }
   22.22  
   22.23 @@ -541,8 +539,7 @@ again:
   22.24      /* Create tuple (path, token). */
   22.25      val = Py_BuildValue("(sO)", xsval[XS_WATCH_PATH], token);
   22.26   exit:
   22.27 -    if (xsval)
   22.28 -        free(xsval);
   22.29 +    free(xsval);
   22.30      return val;
   22.31  }
   22.32  
    23.1 --- a/tools/vtpm_manager/manager/securestorage.c	Fri Nov 11 11:16:46 2005 +0100
    23.2 +++ b/tools/vtpm_manager/manager/securestorage.c	Fri Nov 11 12:55:47 2005 +0100
    23.3 @@ -393,8 +393,7 @@ TPM_RESULT VTPM_LoadService(void) {
    23.4    vtpmlogerror(VTPM_LOG_VTPM, "Failed to load service data with error = %s\n", tpm_get_error_name(status));
    23.5   egress:
    23.6    
    23.7 -  if (flat_global)
    23.8 -    free(flat_global);
    23.9 +  free(flat_global);
   23.10    close(fh);
   23.11    
   23.12    return status;
    24.1 --- a/tools/vtpm_manager/util/bsg.c	Fri Nov 11 11:16:46 2005 +0100
    24.2 +++ b/tools/vtpm_manager/util/bsg.c	Fri Nov 11 12:55:47 2005 +0100
    24.3 @@ -616,8 +616,7 @@ static void BSG_Destroy_private(BSG_Type
    24.4    else if (format == __FMT_SIZE || format == __FMT_HSIZE) {
    24.5      s += size;
    24.6      BSG_BYTE* ptr = *(BSG_BYTE**) s;
    24.7 -    if (ptr)
    24.8 -      free(ptr);
    24.9 +    free(ptr);
   24.10      s += sizeof(void*);
   24.11    } else if (format == __FMT_PACKED) {
   24.12  
    25.1 --- a/tools/xenstat/libxenstat/src/xenstat.c	Fri Nov 11 11:16:46 2005 +0100
    25.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c	Fri Nov 11 12:55:47 2005 +0100
    25.3 @@ -284,10 +284,8 @@ void xenstat_free_node(xenstat_node * no
    25.4  
    25.5  	if (node) {
    25.6  		if (node->domains) {
    25.7 -			for (i = 0; i < node->num_domains; i++) {
    25.8 -				if (node->domains[i].name)
    25.9 -					free(node->domains[i].name);
   25.10 -			}
   25.11 +			for (i = 0; i < node->num_domains; i++)
   25.12 +				free(node->domains[i].name);
   25.13  
   25.14  			for (i = 0; i < NUM_COLLECTORS; i++)
   25.15  				if((node->flags & collectors[i].flag)
    26.1 --- a/tools/xenstore/xenstored_core.c	Fri Nov 11 11:16:46 2005 +0100
    26.2 +++ b/tools/xenstore/xenstored_core.c	Fri Nov 11 12:55:47 2005 +0100
    26.3 @@ -1411,8 +1411,6 @@ static void manual_node(const char *name
    26.4  	talloc_free(node);
    26.5  }
    26.6  
    26.7 -#
    26.8 -
    26.9  static void setup_structure(void)
   26.10  {
   26.11  	char *tdbname;
    27.1 --- a/xen/acm/acm_chinesewall_hooks.c	Fri Nov 11 11:16:46 2005 +0100
    27.2 +++ b/xen/acm/acm_chinesewall_hooks.c	Fri Nov 11 12:55:47 2005 +0100
    27.3 @@ -117,8 +117,7 @@ static int chwall_init_domain_ssid(void 
    27.4  static void chwall_free_domain_ssid(void *chwall_ssid)
    27.5  {
    27.6      traceprintk("%s.\n", __func__);
    27.7 -    if (chwall_ssid != NULL)
    27.8 -        xfree(chwall_ssid);
    27.9 +    xfree(chwall_ssid);
   27.10      return;
   27.11  }
   27.12  
   27.13 @@ -344,14 +343,10 @@ static int chwall_set_policy(u8 * buf, u
   27.14      chwall_bin_pol.max_types = chwall_buf->chwall_max_types;
   27.15      chwall_bin_pol.max_ssidrefs = chwall_buf->chwall_max_ssidrefs;
   27.16      chwall_bin_pol.max_conflictsets = chwall_buf->chwall_max_conflictsets;
   27.17 -    if (chwall_bin_pol.ssidrefs != NULL)
   27.18 -        xfree(chwall_bin_pol.ssidrefs);
   27.19 -    if (chwall_bin_pol.conflict_aggregate_set != NULL)
   27.20 -        xfree(chwall_bin_pol.conflict_aggregate_set);
   27.21 -    if (chwall_bin_pol.running_types != NULL)
   27.22 -        xfree(chwall_bin_pol.running_types);
   27.23 -    if (chwall_bin_pol.conflict_sets != NULL)
   27.24 -        xfree(chwall_bin_pol.conflict_sets);
   27.25 +    xfree(chwall_bin_pol.ssidrefs);
   27.26 +    xfree(chwall_bin_pol.conflict_aggregate_set);
   27.27 +    xfree(chwall_bin_pol.running_types);
   27.28 +    xfree(chwall_bin_pol.conflict_sets);
   27.29      chwall_bin_pol.ssidrefs = ssids;
   27.30      chwall_bin_pol.conflict_aggregate_set = conflict_aggregate_set;
   27.31      chwall_bin_pol.running_types = running_types;
   27.32 @@ -360,14 +355,10 @@ static int chwall_set_policy(u8 * buf, u
   27.33  
   27.34   error_free:
   27.35      printk("%s: ERROR setting policy.\n", __func__);
   27.36 -    if (ssids != NULL)
   27.37 -        xfree(ssids);
   27.38 -    if (conflict_sets != NULL)
   27.39 -        xfree(conflict_sets);
   27.40 -    if (running_types != NULL)
   27.41 -        xfree(running_types);
   27.42 -    if (conflict_aggregate_set != NULL)
   27.43 -        xfree(conflict_aggregate_set);
   27.44 +    xfree(ssids);
   27.45 +    xfree(conflict_sets);
   27.46 +    xfree(running_types);
   27.47 +    xfree(conflict_aggregate_set);
   27.48      return -EFAULT;
   27.49  }
   27.50  
    28.1 --- a/xen/acm/acm_simple_type_enforcement_hooks.c	Fri Nov 11 11:16:46 2005 +0100
    28.2 +++ b/xen/acm/acm_simple_type_enforcement_hooks.c	Fri Nov 11 12:55:47 2005 +0100
    28.3 @@ -130,8 +130,7 @@ static void
    28.4  ste_free_domain_ssid(void *ste_ssid)
    28.5  {
    28.6      traceprintk("%s.\n", __func__);
    28.7 -    if (ste_ssid != NULL)
    28.8 -        xfree(ste_ssid);
    28.9 +    xfree(ste_ssid);
   28.10      return;
   28.11  }
   28.12  
   28.13 @@ -320,8 +319,7 @@ ste_set_policy(u8 *buf, u32 buf_size)
   28.14      /* 3. replace old policy (activate new policy) */
   28.15      ste_bin_pol.max_types = ste_buf->ste_max_types;
   28.16      ste_bin_pol.max_ssidrefs = ste_buf->ste_max_ssidrefs;
   28.17 -    if (ste_bin_pol.ssidrefs) 
   28.18 -        xfree(ste_bin_pol.ssidrefs);
   28.19 +    xfree(ste_bin_pol.ssidrefs);
   28.20      ste_bin_pol.ssidrefs = (domaintype_t *)ssidrefsbuf;
   28.21  
   28.22      /* clear all ste caches */
   28.23 @@ -338,7 +336,7 @@ ste_set_policy(u8 *buf, u32 buf_size)
   28.24  
   28.25   error_free:
   28.26      printk("%s: ERROR setting policy.\n", __func__);
   28.27 -    if (ssidrefsbuf != NULL) xfree(ssidrefsbuf);
   28.28 +    xfree(ssidrefsbuf);
   28.29      return -EFAULT;
   28.30  }
   28.31  
    29.1 --- a/xen/arch/ia64/xen/grant_table.c	Fri Nov 11 11:16:46 2005 +0100
    29.2 +++ b/xen/arch/ia64/xen/grant_table.c	Fri Nov 11 12:55:47 2005 +0100
    29.3 @@ -1348,8 +1348,7 @@ grant_table_create(
    29.4      if ( t != NULL )
    29.5      {
    29.6          xfree(t->active);
    29.7 -        if ( t->maptrack != NULL )
    29.8 -            free_xenheap_page(t->maptrack);
    29.9 +        free_xenheap_page(t->maptrack);
   29.10          xfree(t);
   29.11      }
   29.12      return -ENOMEM;
    30.1 --- a/xen/arch/x86/mm.c	Fri Nov 11 11:16:46 2005 +0100
    30.2 +++ b/xen/arch/x86/mm.c	Fri Nov 11 12:55:47 2005 +0100
    30.3 @@ -3369,10 +3369,8 @@ int ptwr_init(struct domain *d)
    30.4  
    30.5      if ( (x == NULL) || (y == NULL) )
    30.6      {
    30.7 -        if ( x != NULL )
    30.8 -            free_xenheap_page(x);
    30.9 -        if ( y != NULL )
   30.10 -            free_xenheap_page(y);
   30.11 +        free_xenheap_page(x);
   30.12 +        free_xenheap_page(y);
   30.13          return -ENOMEM;
   30.14      }
   30.15  
    31.1 --- a/xen/arch/x86/mtrr/generic.c	Fri Nov 11 11:16:46 2005 +0100
    31.2 +++ b/xen/arch/x86/mtrr/generic.c	Fri Nov 11 12:55:47 2005 +0100
    31.3 @@ -71,8 +71,7 @@ void __init get_mtrr_state(void)
    31.4  /*  Free resources associated with a struct mtrr_state  */
    31.5  void __init finalize_mtrr_state(void)
    31.6  {
    31.7 -	if (mtrr_state.var_ranges)
    31.8 -		xfree(mtrr_state.var_ranges);
    31.9 +	xfree(mtrr_state.var_ranges);
   31.10  	mtrr_state.var_ranges = NULL;
   31.11  }
   31.12  
    32.1 --- a/xen/arch/x86/vmx_vmcs.c	Fri Nov 11 11:16:46 2005 +0100
    32.2 +++ b/xen/arch/x86/vmx_vmcs.c	Fri Nov 11 12:55:47 2005 +0100
    32.3 @@ -564,19 +564,14 @@ err_out:
    32.4  
    32.5  void destroy_vmcs(struct arch_vmx_struct *arch_vmx)
    32.6  {
    32.7 -    if(arch_vmx->vmcs != NULL)
    32.8 -        free_vmcs(arch_vmx->vmcs);
    32.9 -    if(arch_vmx->io_bitmap_a != 0) {
   32.10 -        free_xenheap_pages(
   32.11 -            arch_vmx->io_bitmap_a, get_order_from_bytes(0x1000));
   32.12 -        arch_vmx->io_bitmap_a = 0;
   32.13 -    }
   32.14 -    if(arch_vmx->io_bitmap_b != 0) {
   32.15 -        free_xenheap_pages(
   32.16 -            arch_vmx->io_bitmap_b, get_order_from_bytes(0x1000));
   32.17 -        arch_vmx->io_bitmap_b = 0;
   32.18 -    }
   32.19 -    arch_vmx->vmcs = 0;
   32.20 +    free_vmcs(arch_vmx->vmcs);
   32.21 +    arch_vmx->vmcs = NULL;
   32.22 +
   32.23 +    free_xenheap_pages(arch_vmx->io_bitmap_a, get_order_from_bytes(0x1000));
   32.24 +    arch_vmx->io_bitmap_a = NULL;
   32.25 +
   32.26 +    free_xenheap_pages(arch_vmx->io_bitmap_b, get_order_from_bytes(0x1000));
   32.27 +    arch_vmx->io_bitmap_b = NULL;
   32.28  }
   32.29  
   32.30  /*
    33.1 --- a/xen/common/event_channel.c	Fri Nov 11 11:16:46 2005 +0100
    33.2 +++ b/xen/common/event_channel.c	Fri Nov 11 12:55:47 2005 +0100
    33.3 @@ -621,8 +621,7 @@ void evtchn_destroy(struct domain *d)
    33.4              (void)__evtchn_close(d, i);
    33.5  
    33.6      for ( i = 0; i < NR_EVTCHN_BUCKETS; i++ )
    33.7 -        if ( d->evtchn[i] != NULL )
    33.8 -            xfree(d->evtchn[i]);
    33.9 +        xfree(d->evtchn[i]);
   33.10  }
   33.11  
   33.12  /*
    34.1 --- a/xen/common/grant_table.c	Fri Nov 11 11:16:46 2005 +0100
    34.2 +++ b/xen/common/grant_table.c	Fri Nov 11 12:55:47 2005 +0100
    34.3 @@ -1107,8 +1107,7 @@ grant_table_create(
    34.4      if ( t != NULL )
    34.5      {
    34.6          xfree(t->active);
    34.7 -        if ( t->maptrack != NULL )
    34.8 -            free_xenheap_page(t->maptrack);
    34.9 +        free_xenheap_page(t->maptrack);
   34.10          xfree(t);
   34.11      }
   34.12      return -ENOMEM;
    35.1 --- a/xen/common/page_alloc.c	Fri Nov 11 11:16:46 2005 +0100
    35.2 +++ b/xen/common/page_alloc.c	Fri Nov 11 12:55:47 2005 +0100
    35.3 @@ -470,6 +470,9 @@ void free_xenheap_pages(void *v, unsigne
    35.4  {
    35.5      unsigned long flags;
    35.6  
    35.7 +    if ( v == NULL )
    35.8 +        return;
    35.9 +
   35.10      memguard_guard_range(v, 1 << (order + PAGE_SHIFT));    
   35.11  
   35.12      local_irq_save(flags);