WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Remove unnecessary NULL checks before freeing memory blo

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Remove unnecessary NULL checks before freeing memory blocks.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 11 Nov 2005 16:26:17 +0000
Delivery-date: Fri, 11 Nov 2005 16:27:48 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID fcb7e5616102d68205815e810feef6ef90c1515b
# Parent  41c8a2ea07c0df8c4fd69f5d4a6343eae89569ec
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@xxxxxxxxxxxxx>

diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c
--- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c   Fri Nov 11 10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c   Fri Nov 11 11:55:47 2005
@@ -97,9 +97,7 @@
 transmission_set_buffer(struct transmission *t,
                         unsigned char *buffer, unsigned int len)
 {
-       if (NULL != t->request) {
-               kfree(t->request);
-       }
+       kfree(t->request);
        t->request = kmalloc(len, GFP_KERNEL);
        if (t->request) {
                memcpy(t->request,
@@ -113,12 +111,8 @@
 static inline void
 transmission_free(struct transmission *t)
 {
-       if (t->request) {
-               kfree(t->request);
-       }
-       if (t->rcv_buffer) {
-               kfree(t->rcv_buffer);
-       }
+       kfree(t->request);
+       kfree(t->rcv_buffer);
        kfree(t);
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Nov 11 10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Fri Nov 11 11:55:47 2005
@@ -48,8 +48,7 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->blkif)
                blkif_put(be->blkif);
-       if (be->frontpath)
-               kfree(be->frontpath);
+       kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -274,8 +273,7 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       if (frontend)
-               kfree(frontend);
+       kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Nov 11 
10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c      Fri Nov 11 
11:55:47 2005
@@ -607,8 +607,7 @@
  destroy_blkring:
        blkif_free(info);
  out:
-       if (backend)
-               kfree(backend);
+       kfree(backend);
        return err;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Fri Nov 11 10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/blktap/xenbus.c  Fri Nov 11 11:55:47 2005
@@ -52,8 +52,7 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->blkif)
                blkif_put(be->blkif);
-       if (be->frontpath)
-               kfree(be->frontpath);
+       kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -201,8 +200,7 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       if (frontend)
-               kfree(frontend);
+       kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/netback/loopback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c       Fri Nov 11 
10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/loopback.c       Fri Nov 11 
11:55:47 2005
@@ -160,10 +160,8 @@
        return 0;
 
  fail:
-       if (dev1 != NULL)
-               kfree(dev1);
-       if (dev2 != NULL)
-               kfree(dev2);
+       kfree(dev1);
+       kfree(dev2);
        return err;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Fri Nov 11 10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Fri Nov 11 11:55:47 2005
@@ -46,8 +46,7 @@
        unregister_xenbus_watch(&be->backend_watch);
        if (be->netif)
                netif_disconnect(be->netif);
-       if (be->frontpath)
-               kfree(be->frontpath);
+       kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -253,8 +252,7 @@
  free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       if (frontend)
-               kfree(frontend);
+       kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri Nov 11 
10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Fri Nov 11 
11:55:47 2005
@@ -917,7 +917,7 @@
        np->netdev = netdev;
 
  exit:
-       if ((err != 0) && (netdev != NULL))
+       if (err != 0)
                kfree(netdev);
        else if (val != NULL)
                *val = netdev;
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Nov 11 
10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/tpmback.c        Fri Nov 11 
11:55:47 2005
@@ -167,9 +167,7 @@
 packet_free(struct packet *pak)
 {
        del_singleshot_timer_sync(&pak->processing_timer);
-       if (pak->data_buffer) {
-               kfree(pak->data_buffer);
-       }
+       kfree(pak->data_buffer);
        /*
         * cannot do tpmif_put(pak->tpmif); bad things happen
         * on the last tpmif_put()
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Fri Nov 11 10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c Fri Nov 11 11:55:47 2005
@@ -41,19 +41,16 @@
 {
        struct backend_info *be = dev->data;
 
-       if (be->watch.node) {
+       if (be->watch.node)
                unregister_xenbus_watch(&be->watch);
-       }
        unregister_xenbus_watch(&be->backend_watch);
 
        tpmif_vtpm_close(be->instance);
 
-       if (be->tpmif) {
+       if (be->tpmif)
                tpmif_put(be->tpmif);
-       }
-
-       if (be->frontpath)
-               kfree(be->frontpath);
+
+       kfree(be->frontpath);
        kfree(be);
        return 0;
 }
@@ -258,8 +255,7 @@
 free_be:
        if (be->backend_watch.node)
                unregister_xenbus_watch(&be->backend_watch);
-       if (frontend)
-               kfree(frontend);
+       kfree(frontend);
        kfree(be);
        return err;
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Fri Nov 11 
10:16:46 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c      Fri Nov 11 
11:55:47 2005
@@ -387,8 +387,7 @@
 destroy_tpmring:
        destroy_tpmring(info, &my_private);
 out:
-       if (backend)
-               kfree(backend);
+       kfree(backend);
        return err;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/blktap/blkif.c
--- a/tools/blktap/blkif.c      Fri Nov 11 10:16:46 2005
+++ b/tools/blktap/blkif.c      Fri Nov 11 11:55:47 2005
@@ -108,8 +108,7 @@
         }
         pblkif = &curs->hash_next;
     }
-    if (blkif != NULL)
-        free(blkif);
+    free(blkif);
 }
 
 void blkif_register_request_hook(blkif_t *blkif, char *name, 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/blktap/parallax/blockstore.c
--- a/tools/blktap/parallax/blockstore.c        Fri Nov 11 10:16:46 2005
+++ b/tools/blktap/parallax/blockstore.c        Fri Nov 11 11:55:47 2005
@@ -604,8 +604,7 @@
     return block;
 
     err:
-    if (qe->block)
-        free(qe->block);
+    free(qe->block);
     free((void *)qe);
     return NULL;
 }
@@ -1072,7 +1071,7 @@
  *
  *   @return: pointer to new block, NULL on error
  */
-void *newblock() {
+void *newblock(void) {
     void *block = malloc(BLOCK_SIZE);
     if (block == NULL) {
         perror("newblock");
@@ -1089,7 +1088,6 @@
  *   @block: block to be freed
  */
 void freeblock(void *block) {
-    if (block != NULL)
         free(block);
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/blktap/parallax/blockstored.c
--- a/tools/blktap/parallax/blockstored.c       Fri Nov 11 10:16:46 2005
+++ b/tools/blktap/parallax/blockstored.c       Fri Nov 11 11:55:47 2005
@@ -232,7 +232,7 @@
  *
  *   @return: pointer to new block, NULL on error
  */
-void *newblock() {
+void *newblock(void) {
     void *block = malloc(BLOCK_SIZE);
     if (block == NULL) {
         perror("newblock");
@@ -249,7 +249,6 @@
  *   @block: block to be freed
  */
 void freeblock(void *block) {
-    if (block != NULL)
         free(block);
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/blktap/parallax/requests-async.c
--- a/tools/blktap/parallax/requests-async.c    Fri Nov 11 10:16:46 2005
+++ b/tools/blktap/parallax/requests-async.c    Fri Nov 11 11:55:47 2005
@@ -715,7 +715,7 @@
         r.u.i  = -1;
         /* free any saved node vals. */
         for (i=0; i<3; i++)
-            if (req->radix[i] != 0) free(req->radix[i]);
+            free(req->radix[i]);
         free(req);
         cb(r, req_param);
     }
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/blktap/xenbus.c
--- a/tools/blktap/xenbus.c     Fri Nov 11 10:16:46 2005
+++ b/tools/blktap/xenbus.c     Fri Nov 11 11:55:47 2005
@@ -339,10 +339,8 @@
     /* Free everything else. */
     if (be->blkif)
         free_blkif(be->blkif);
-    if (be->frontpath)
-        free(be->frontpath);
-    if (be->backpath)
-        free(be->backpath);
+    free(be->frontpath);
+    free(be->backpath);
     free(be);
     return 0;
 }
@@ -406,8 +404,7 @@
     return;
 
  fail:
-    if (fepath)
-        free(fepath);
+    free(fepath);
 }
 
 
@@ -460,9 +457,7 @@
     }
 
  fail:
-    if (path)
-        free(path);
-
+    free(path);
 }
 
 static void blkback_probe(struct xs_handle *h, struct xenbus_watch *w, 
@@ -537,12 +532,10 @@
        return;
 
  free_be:
-       if ((be) && (be->backend_watch.node))
+       if (be && (be->backend_watch.node))
             unregister_xenbus_watch(h, &be->backend_watch);
-       if (frontend)
-            free(frontend);
-        if (bepath)
-            free(bepath);
+        free(frontend);
+        free(bepath);
        free(be);
        return;
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Fri Nov 11 10:16:46 2005
+++ b/tools/console/daemon/io.c Fri Nov 11 11:55:47 2005
@@ -344,8 +344,7 @@
 
        return dom;
  out:
-       if (dom->conspath)
-               free(dom->conspath);
+       free(dom->conspath);
        free(dom);
        return NULL;
 }
@@ -380,20 +379,16 @@
        if (!buffer_empty(&d->buffer))
                return;
 
-       if (d->buffer.data) {
-               free(d->buffer.data);
-               d->buffer.data = NULL;
-       }
-
        if (d->tty_fd != -1) {
                close(d->tty_fd);
                d->tty_fd = -1;
        }
 
-       if (d->conspath) {
-               free(d->conspath);
-               d->conspath = NULL;
-       }
+       free(d->buffer.data);
+       d->buffer.data = NULL;
+
+       free(d->conspath);
+       d->conspath = NULL;
 
        remove_domain(d);
 }
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/ioemu/hw/magic-load.c
--- a/tools/ioemu/hw/magic-load.c       Fri Nov 11 10:16:46 2005
+++ b/tools/ioemu/hw/magic-load.c       Fri Nov 11 11:55:47 2005
@@ -196,10 +196,8 @@
        goto error_freesyms;
 
     /* Commit */
-    if (disas_symtab)
-       qemu_free(disas_symtab); /* XXX Merge with old symbols? */
-    if (disas_strtab)
-       qemu_free(disas_strtab);
+    qemu_free(disas_symtab); /* XXX Merge with old symbols? */
+    qemu_free(disas_strtab);
     disas_symtab = syms;
     disas_num_syms = nsyms;
     disas_strtab = str;
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Fri Nov 11 10:16:46 2005
+++ b/tools/ioemu/vnc.c Fri Nov 11 11:55:47 2005
@@ -187,8 +187,7 @@
 
 static void start_mouse_calibration() {
        int size = screen->height*screen->paddedWidthInBytes;
-       if(mouse_magic->calibration)
-               free(mouse_magic->calibration);
+       free(mouse_magic->calibration);
        mouse_magic->calibration = malloc(size);
        memcpy(mouse_magic->calibration, screen->frameBuffer, size);
        calibration_step=0;
@@ -198,8 +197,7 @@
 }
 
 static void stop_mouse_calibration() {
-       if(mouse_magic->calibration)
-               free(mouse_magic->calibration);
+       free(mouse_magic->calibration);
        mouse_magic->calibration = 0;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/libxc/xc_ia64_stubs.c
--- a/tools/libxc/xc_ia64_stubs.c       Fri Nov 11 10:16:46 2005
+++ b/tools/libxc/xc_ia64_stubs.c       Fri Nov 11 11:55:47 2005
@@ -77,7 +77,7 @@
 {
     // N.B. gva should be page aligned
     
-    unsigned long *page_array=NULL;
+    unsigned long *page_array = NULL;
     int i;
 
     if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL ){
@@ -99,8 +99,7 @@
     return 0;
     
 error_out:
-    if (page_array)
-        free(page_array);
+    free(page_array);
     return -1;
 }
 
@@ -657,8 +656,7 @@
         goto error_out;
     }
 
-    if ( image != NULL )
-        free(image);
+    free(image);
 
     ctxt->flags = VGCF_VMX_GUEST;
     ctxt->regs.cr_iip = 0x80000000ffffffb0UL;
@@ -675,9 +673,7 @@
     return rc;
 
  error_out:
-    if ( image != NULL )
-        free(image);
-
+    free(image);
     return -1;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Fri Nov 11 10:16:46 2005
+++ b/tools/libxc/xc_linux_build.c      Fri Nov 11 11:55:47 2005
@@ -670,10 +670,8 @@
     return 0;
 
  error_out:
-    if ( mmu != NULL )
-        free(mmu);
-    if ( page_array != NULL )
-        free(page_array);
+    free(mmu);
+    free(page_array);
     return -1;
 }
 #endif
@@ -768,8 +766,7 @@
         close(initrd_fd);
     if ( initrd_gfd )
         gzclose(initrd_gfd);
-    if ( image != NULL )
-        free(image);
+    free(image);
 
 #ifdef __ia64__
     /* based on new_thread in xen/arch/ia64/domain.c */
@@ -858,9 +855,7 @@
         gzclose(initrd_gfd);
     else if ( initrd_fd >= 0 )
         close(initrd_fd);
-    if ( image != NULL )
-        free(image);
-
+    free(image);
     return -1;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/libxc/xc_vmx_build.c
--- a/tools/libxc/xc_vmx_build.c        Fri Nov 11 10:16:46 2005
+++ b/tools/libxc/xc_vmx_build.c        Fri Nov 11 11:55:47 2005
@@ -565,10 +565,8 @@
     return 0;
 
  error_out:
-    if ( mmu != NULL )
-        free(mmu);
-    if ( page_array != NULL )
-        free(page_array);
+    free(mmu);
+    free(page_array);
     return -1;
 }
 
@@ -663,8 +661,7 @@
         goto error_out;
     }
 
-    if ( image != NULL )
-        free(image);
+    free(image);
 
     ctxt->flags = VGCF_VMX_GUEST;
     /* FPU is set up to default initial state. */
@@ -710,9 +707,7 @@
     return rc;
 
  error_out:
-    if ( image != NULL )
-        free(image);
-
+    free(image);
     return -1;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Fri Nov 11 10:16:46 2005
+++ b/tools/python/xen/lowlevel/xs/xs.c Fri Nov 11 11:55:47 2005
@@ -114,8 +114,7 @@
     }
     val = PyString_FromStringAndSize(xsval, xsval_n);
  exit:
-    if (xsval)
-        free(xsval);
+    free(xsval);
     return val;
 }
 
@@ -427,8 +426,7 @@
     val = Py_None;
  exit:
     Py_XDECREF(tuple0);
-    if (xsperms)
-        free(xsperms);
+    free(xsperms);
     return val;
 }
 
@@ -541,8 +539,7 @@
     /* Create tuple (path, token). */
     val = Py_BuildValue("(sO)", xsval[XS_WATCH_PATH], token);
  exit:
-    if (xsval)
-        free(xsval);
+    free(xsval);
     return val;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/vtpm_manager/manager/securestorage.c
--- a/tools/vtpm_manager/manager/securestorage.c        Fri Nov 11 10:16:46 2005
+++ b/tools/vtpm_manager/manager/securestorage.c        Fri Nov 11 11:55:47 2005
@@ -393,8 +393,7 @@
   vtpmlogerror(VTPM_LOG_VTPM, "Failed to load service data with error = %s\n", 
tpm_get_error_name(status));
  egress:
   
-  if (flat_global)
-    free(flat_global);
+  free(flat_global);
   close(fh);
   
   return status;
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/vtpm_manager/util/bsg.c
--- a/tools/vtpm_manager/util/bsg.c     Fri Nov 11 10:16:46 2005
+++ b/tools/vtpm_manager/util/bsg.c     Fri Nov 11 11:55:47 2005
@@ -616,8 +616,7 @@
   else if (format == __FMT_SIZE || format == __FMT_HSIZE) {
     s += size;
     BSG_BYTE* ptr = *(BSG_BYTE**) s;
-    if (ptr)
-      free(ptr);
+    free(ptr);
     s += sizeof(void*);
   } else if (format == __FMT_PACKED) {
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Fri Nov 11 10:16:46 2005
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Fri Nov 11 11:55:47 2005
@@ -284,10 +284,8 @@
 
        if (node) {
                if (node->domains) {
-                       for (i = 0; i < node->num_domains; i++) {
-                               if (node->domains[i].name)
-                                       free(node->domains[i].name);
-                       }
+                       for (i = 0; i < node->num_domains; i++)
+                               free(node->domains[i].name);
 
                        for (i = 0; i < NUM_COLLECTORS; i++)
                                if((node->flags & collectors[i].flag)
diff -r 41c8a2ea07c0 -r fcb7e5616102 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Fri Nov 11 10:16:46 2005
+++ b/tools/xenstore/xenstored_core.c   Fri Nov 11 11:55:47 2005
@@ -1410,8 +1410,6 @@
                barf_perror("Could not create initial node %s", name);
        talloc_free(node);
 }
-
-#
 
 static void setup_structure(void)
 {
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/acm/acm_chinesewall_hooks.c
--- a/xen/acm/acm_chinesewall_hooks.c   Fri Nov 11 10:16:46 2005
+++ b/xen/acm/acm_chinesewall_hooks.c   Fri Nov 11 11:55:47 2005
@@ -117,8 +117,7 @@
 static void chwall_free_domain_ssid(void *chwall_ssid)
 {
     traceprintk("%s.\n", __func__);
-    if (chwall_ssid != NULL)
-        xfree(chwall_ssid);
+    xfree(chwall_ssid);
     return;
 }
 
@@ -344,14 +343,10 @@
     chwall_bin_pol.max_types = chwall_buf->chwall_max_types;
     chwall_bin_pol.max_ssidrefs = chwall_buf->chwall_max_ssidrefs;
     chwall_bin_pol.max_conflictsets = chwall_buf->chwall_max_conflictsets;
-    if (chwall_bin_pol.ssidrefs != NULL)
-        xfree(chwall_bin_pol.ssidrefs);
-    if (chwall_bin_pol.conflict_aggregate_set != NULL)
-        xfree(chwall_bin_pol.conflict_aggregate_set);
-    if (chwall_bin_pol.running_types != NULL)
-        xfree(chwall_bin_pol.running_types);
-    if (chwall_bin_pol.conflict_sets != NULL)
-        xfree(chwall_bin_pol.conflict_sets);
+    xfree(chwall_bin_pol.ssidrefs);
+    xfree(chwall_bin_pol.conflict_aggregate_set);
+    xfree(chwall_bin_pol.running_types);
+    xfree(chwall_bin_pol.conflict_sets);
     chwall_bin_pol.ssidrefs = ssids;
     chwall_bin_pol.conflict_aggregate_set = conflict_aggregate_set;
     chwall_bin_pol.running_types = running_types;
@@ -360,14 +355,10 @@
 
  error_free:
     printk("%s: ERROR setting policy.\n", __func__);
-    if (ssids != NULL)
-        xfree(ssids);
-    if (conflict_sets != NULL)
-        xfree(conflict_sets);
-    if (running_types != NULL)
-        xfree(running_types);
-    if (conflict_aggregate_set != NULL)
-        xfree(conflict_aggregate_set);
+    xfree(ssids);
+    xfree(conflict_sets);
+    xfree(running_types);
+    xfree(conflict_aggregate_set);
     return -EFAULT;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c       Fri Nov 11 10:16:46 2005
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c       Fri Nov 11 11:55:47 2005
@@ -130,8 +130,7 @@
 ste_free_domain_ssid(void *ste_ssid)
 {
     traceprintk("%s.\n", __func__);
-    if (ste_ssid != NULL)
-        xfree(ste_ssid);
+    xfree(ste_ssid);
     return;
 }
 
@@ -320,8 +319,7 @@
     /* 3. replace old policy (activate new policy) */
     ste_bin_pol.max_types = ste_buf->ste_max_types;
     ste_bin_pol.max_ssidrefs = ste_buf->ste_max_ssidrefs;
-    if (ste_bin_pol.ssidrefs) 
-        xfree(ste_bin_pol.ssidrefs);
+    xfree(ste_bin_pol.ssidrefs);
     ste_bin_pol.ssidrefs = (domaintype_t *)ssidrefsbuf;
 
     /* clear all ste caches */
@@ -338,7 +336,7 @@
 
  error_free:
     printk("%s: ERROR setting policy.\n", __func__);
-    if (ssidrefsbuf != NULL) xfree(ssidrefsbuf);
+    xfree(ssidrefsbuf);
     return -EFAULT;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/arch/ia64/xen/grant_table.c
--- a/xen/arch/ia64/xen/grant_table.c   Fri Nov 11 10:16:46 2005
+++ b/xen/arch/ia64/xen/grant_table.c   Fri Nov 11 11:55:47 2005
@@ -1348,8 +1348,7 @@
     if ( t != NULL )
     {
         xfree(t->active);
-        if ( t->maptrack != NULL )
-            free_xenheap_page(t->maptrack);
+        free_xenheap_page(t->maptrack);
         xfree(t);
     }
     return -ENOMEM;
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Fri Nov 11 10:16:46 2005
+++ b/xen/arch/x86/mm.c Fri Nov 11 11:55:47 2005
@@ -3369,10 +3369,8 @@
 
     if ( (x == NULL) || (y == NULL) )
     {
-        if ( x != NULL )
-            free_xenheap_page(x);
-        if ( y != NULL )
-            free_xenheap_page(y);
+        free_xenheap_page(x);
+        free_xenheap_page(y);
         return -ENOMEM;
     }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/arch/x86/mtrr/generic.c
--- a/xen/arch/x86/mtrr/generic.c       Fri Nov 11 10:16:46 2005
+++ b/xen/arch/x86/mtrr/generic.c       Fri Nov 11 11:55:47 2005
@@ -71,8 +71,7 @@
 /*  Free resources associated with a struct mtrr_state  */
 void __init finalize_mtrr_state(void)
 {
-       if (mtrr_state.var_ranges)
-               xfree(mtrr_state.var_ranges);
+       xfree(mtrr_state.var_ranges);
        mtrr_state.var_ranges = NULL;
 }
 
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/arch/x86/vmx_vmcs.c
--- a/xen/arch/x86/vmx_vmcs.c   Fri Nov 11 10:16:46 2005
+++ b/xen/arch/x86/vmx_vmcs.c   Fri Nov 11 11:55:47 2005
@@ -564,19 +564,14 @@
 
 void destroy_vmcs(struct arch_vmx_struct *arch_vmx)
 {
-    if(arch_vmx->vmcs != NULL)
-        free_vmcs(arch_vmx->vmcs);
-    if(arch_vmx->io_bitmap_a != 0) {
-        free_xenheap_pages(
-            arch_vmx->io_bitmap_a, get_order_from_bytes(0x1000));
-        arch_vmx->io_bitmap_a = 0;
-    }
-    if(arch_vmx->io_bitmap_b != 0) {
-        free_xenheap_pages(
-            arch_vmx->io_bitmap_b, get_order_from_bytes(0x1000));
-        arch_vmx->io_bitmap_b = 0;
-    }
-    arch_vmx->vmcs = 0;
+    free_vmcs(arch_vmx->vmcs);
+    arch_vmx->vmcs = NULL;
+
+    free_xenheap_pages(arch_vmx->io_bitmap_a, get_order_from_bytes(0x1000));
+    arch_vmx->io_bitmap_a = NULL;
+
+    free_xenheap_pages(arch_vmx->io_bitmap_b, get_order_from_bytes(0x1000));
+    arch_vmx->io_bitmap_b = NULL;
 }
 
 /*
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/common/event_channel.c
--- a/xen/common/event_channel.c        Fri Nov 11 10:16:46 2005
+++ b/xen/common/event_channel.c        Fri Nov 11 11:55:47 2005
@@ -621,8 +621,7 @@
             (void)__evtchn_close(d, i);
 
     for ( i = 0; i < NR_EVTCHN_BUCKETS; i++ )
-        if ( d->evtchn[i] != NULL )
-            xfree(d->evtchn[i]);
+        xfree(d->evtchn[i]);
 }
 
 /*
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Fri Nov 11 10:16:46 2005
+++ b/xen/common/grant_table.c  Fri Nov 11 11:55:47 2005
@@ -1107,8 +1107,7 @@
     if ( t != NULL )
     {
         xfree(t->active);
-        if ( t->maptrack != NULL )
-            free_xenheap_page(t->maptrack);
+        free_xenheap_page(t->maptrack);
         xfree(t);
     }
     return -ENOMEM;
diff -r 41c8a2ea07c0 -r fcb7e5616102 xen/common/page_alloc.c
--- a/xen/common/page_alloc.c   Fri Nov 11 10:16:46 2005
+++ b/xen/common/page_alloc.c   Fri Nov 11 11:55:47 2005
@@ -470,6 +470,9 @@
 {
     unsigned long flags;
 
+    if ( v == NULL )
+        return;
+
     memguard_guard_range(v, 1 << (order + PAGE_SHIFT));    
 
     local_irq_save(flags);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Remove unnecessary NULL checks before freeing memory blocks., Xen patchbot -unstable <=