[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] remove unnecessary null pointer checks before frees



Matthew Daley, le Sun 29 Sep 2013 16:26:58 +1300, a écrit :
> Oops, spatch removed an #if 0'd hunk from gtraceview.c. Here's a fixed 
> version:
> 
> -- 8< --
> 
> Patch generated by the following semantic patch
> (http://coccinelle.lip6.fr/):
> 
> @@
> expression *P;
> @@
> 
> - if(P) free(P);
> + free(P);
> 
> ...and then by filtering through the following command:
> 
> filterdiff -p1 -x 'stubdom/*' -x 'tools/firmware/*' -x 'tools/qemu-*'
> 
> Signed-off-by: Matthew Daley <mattjd@xxxxxxxxx>

Acked-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

> ---
>  extras/mini-os/blkfront.c            |   14 ++++++-------
>  extras/mini-os/console/xenbus.c      |    8 +++----
>  extras/mini-os/fbfront.c             |   38 
> +++++++++++++++++-----------------
>  extras/mini-os/kernel.c              |    4 ++--
>  extras/mini-os/lib/sys.c             |    3 +--
>  extras/mini-os/netfront.c            |   18 ++++++++--------
>  extras/mini-os/pcifront.c            |   14 ++++++-------
>  tools/blktap/drivers/blktapctrl.c    |    6 ++----
>  tools/blktap/drivers/tapaio.c        |   18 ++++++----------
>  tools/blktap/drivers/tapdisk.c       |    9 +++-----
>  tools/blktap/lib/xenbus.c            |   21 +++++++------------
>  tools/blktap/lib/xs_api.c            |    3 +--
>  tools/blktap2/control/tap-ctl-list.c |    6 ++----
>  tools/blktap2/drivers/block-log.c    |    3 +--
>  tools/flask/utils/loadpolicy.c       |    3 +--
>  tools/libxc/xc_compression.c         |   15 +++++---------
>  tools/libxc/xc_core_x86.c            |    6 ++----
>  tools/libxc/xc_domain_save.c         |    6 ++----
>  tools/libxc/xc_gnttab.c              |    3 +--
>  tools/libxc/xc_offline_page.c        |    9 +++-----
>  tools/libxl/libxl_event.c            |    3 +--
>  tools/libxl/libxl_qmp.c              |    6 ++----
>  tools/libxl/libxl_utils.c            |    2 +-
>  tools/memshr/bidir-hash.c            |    4 ++--
>  tools/misc/gtraceview.c              |    3 +--
>  tools/tests/xen-access/xen-access.c  |    6 ++----
>  tools/xenbackendd/xenbackendd.c      |    6 ++----
>  27 files changed, 96 insertions(+), 141 deletions(-)
> 
> diff --git a/extras/mini-os/blkfront.c b/extras/mini-os/blkfront.c
> index aead6bd..62a32c5 100644
> --- a/extras/mini-os/blkfront.c
> +++ b/extras/mini-os/blkfront.c
> @@ -160,7 +160,7 @@ again:
>  
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> @@ -271,7 +271,7 @@ void shutdown_blkfront(struct blkfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("shutdown_blkfront: error changing state to %d: %s\n",
> @@ -281,7 +281,7 @@ void shutdown_blkfront(struct blkfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (state < XenbusStateClosed) {
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -        if (err) free(err);
> +        free(err);
>      }
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, 
> XenbusStateInitialising)) != NULL) {
> @@ -294,16 +294,16 @@ void shutdown_blkfront(struct blkfront_dev *dev)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
>  
>  close:
> -    if (err) free(err);
> +    free(err);
>      err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      snprintf(nodename, sizeof(nodename), "%s/ring-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      if (!err)
>          free_blkfront(dev);
> diff --git a/extras/mini-os/console/xenbus.c b/extras/mini-os/console/xenbus.c
> index b317114..1c9a590 100644
> --- a/extras/mini-os/console/xenbus.c
> +++ b/extras/mini-os/console/xenbus.c
> @@ -32,7 +32,7 @@ void free_consfront(struct consfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("free_consfront: error changing state to %d: %s\n",
> @@ -41,9 +41,9 @@ void free_consfront(struct consfront_dev *dev)
>      }
>  
>  close:
> -    if (err) free(err);
> +    free(err);
>      err = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err) free(err);
> +    free(err);
>  
>      mask_evtchn(dev->evtchn);
>      unbind_evtchn(dev->evtchn);
> @@ -134,7 +134,7 @@ again:
>  
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> diff --git a/extras/mini-os/fbfront.c b/extras/mini-os/fbfront.c
> index a276193..1e01513 100644
> --- a/extras/mini-os/fbfront.c
> +++ b/extras/mini-os/fbfront.c
> @@ -131,7 +131,7 @@ again:
>      }
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> @@ -171,7 +171,7 @@ done:
>              err = xenbus_wait_for_state_change(path, &state, &dev->events);
>          if (state != XenbusStateConnected) {
>              printk("backend not available, state=%d\n", state);
> -            if (err) free(err);
> +            free(err);
>              err = xenbus_unwatch_path_token(XBT_NIL, path, path);
>              goto error;
>          }
> @@ -256,7 +256,7 @@ void shutdown_kbdfront(struct kbdfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("shutdown_kbdfront: error changing state to %d: %s\n",
> @@ -266,7 +266,7 @@ void shutdown_kbdfront(struct kbdfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (state < XenbusStateClosed) {
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -        if (err) free(err);
> +        free(err);
>      }
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, 
> XenbusStateInitialising)) != NULL) {
> @@ -279,19 +279,19 @@ void shutdown_kbdfront(struct kbdfront_dev *dev)
>      err = xenbus_wait_for_state_change(path, &state, &dev->events);
>  
>  close_kbdfront:
> -    if (err) free(err);
> +    free(err);
>      err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      snprintf(nodename, sizeof(nodename), "%s/page-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/request-abs-pointer", 
> dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      if (!err)
>          free_kbdfront(dev);
> @@ -498,7 +498,7 @@ again:
>      }
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> @@ -538,7 +538,7 @@ done:
>              err = xenbus_wait_for_state_change(path, &state, &dev->events);
>          if (state != XenbusStateConnected) {
>              printk("backend not available, state=%d\n", state);
> -            if (err) free(err);
> +            free(err);
>              err = xenbus_unwatch_path_token(XBT_NIL, path, path);
>              goto error;
>          }
> @@ -654,7 +654,7 @@ void shutdown_fbfront(struct fbfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("shutdown_fbfront: error changing state to %d: %s\n",
> @@ -664,7 +664,7 @@ void shutdown_fbfront(struct fbfront_dev *dev)
>      state = xenbus_read_integer(path);
>      if (state < XenbusStateClosed) {
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -        if (err) free(err);
> +        free(err);
>      }
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, 
> XenbusStateInitialising)) != NULL) {
> @@ -677,22 +677,22 @@ void shutdown_fbfront(struct fbfront_dev *dev)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
>  
>  close_fbfront:
> -    if (err) free(err);
> +    free(err);
>      err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      snprintf(nodename, sizeof(nodename), "%s/page-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/protocol", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/feature-update", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      if (!err)
>          free_fbfront(dev);
> diff --git a/extras/mini-os/kernel.c b/extras/mini-os/kernel.c
> index 24fa25c..ea409f4 100644
> --- a/extras/mini-os/kernel.c
> +++ b/extras/mini-os/kernel.c
> @@ -85,9 +85,9 @@ static void shutdown_thread(void *p)
>          xenbus_wait_for_watch(&events);
>      }
>      err = xenbus_unwatch_path_token(XBT_NIL, path, token);
> -    if (err) free(err);
> +    free(err);
>      err = xenbus_write(XBT_NIL, path, "");
> -    if (err) free(err);
> +    free(err);
>      printk("Shutting down (%s)\n", shutdown);
>  
>      if (!strcmp(shutdown, "poweroff"))
> diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c
> index cfbdc90..13e7e59 100644
> --- a/extras/mini-os/lib/sys.c
> +++ b/extras/mini-os/lib/sys.c
> @@ -1156,8 +1156,7 @@ LWIP_STUB(int, getsockname, (int s, struct sockaddr 
> *name, socklen_t *namelen),
>  static char *syslog_ident;
>  void openlog(const char *ident, int option, int facility)
>  {
> -    if (syslog_ident)
> -        free(syslog_ident);
> +    free(syslog_ident);
>      syslog_ident = strdup(ident);
>  }
>  
> diff --git a/extras/mini-os/netfront.c b/extras/mini-os/netfront.c
> index 3a5be64..44c3995 100644
> --- a/extras/mini-os/netfront.c
> +++ b/extras/mini-os/netfront.c
> @@ -412,7 +412,7 @@ again:
>      }
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> @@ -525,7 +525,7 @@ void shutdown_netfront(struct netfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("shutdown_netfront: error changing state to %d: %s\n",
> @@ -535,7 +535,7 @@ void shutdown_netfront(struct netfront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (state < XenbusStateClosed) {
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -        if (err) free(err);
> +        free(err);
>      }
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, 
> XenbusStateInitialising)) != NULL) {
> @@ -548,22 +548,22 @@ void shutdown_netfront(struct netfront_dev *dev)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
>  
>  close:
> -    if (err) free(err);
> +    free(err);
>      err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      snprintf(nodename, sizeof(nodename), "%s/tx-ring-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/rx-ring-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/request-rx-copy", 
> dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      if (!err)
>          free_netfront(dev);
> diff --git a/extras/mini-os/pcifront.c b/extras/mini-os/pcifront.c
> index 7838021..16a4b49 100644
> --- a/extras/mini-os/pcifront.c
> +++ b/extras/mini-os/pcifront.c
> @@ -212,7 +212,7 @@ again:
>      }
>  
>      err = xenbus_transaction_end(xbt, 0, &retry);
> -    if (err) free(err);
> +    free(err);
>      if (retry) {
>              goto again;
>          printk("completing transaction\n");
> @@ -251,7 +251,7 @@ done:
>              err = xenbus_wait_for_state_change(path, &state, &dev->events);
>          if (state != XenbusStateConnected) {
>              printk("backend not avalable, state=%d\n", state);
> -            if (err) free(err);
> +            free(err);
>              err = xenbus_unwatch_path_token(XBT_NIL, path, path);
>              goto error;
>          }
> @@ -342,7 +342,7 @@ void shutdown_pcifront(struct pcifront_dev *dev)
>      state = xenbus_read_integer(path);
>      while (err == NULL && state < XenbusStateClosing)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
> -    if (err) free(err);
> +    free(err);
>  
>      if ((err = xenbus_switch_state(XBT_NIL, nodename, XenbusStateClosed)) != 
> NULL) {
>          printk("shutdown_pcifront: error changing state to %d: %s\n",
> @@ -365,16 +365,16 @@ void shutdown_pcifront(struct pcifront_dev *dev)
>          err = xenbus_wait_for_state_change(path, &state, &dev->events);
>  
>  close_pcifront:
> -    if (err) free(err);
> +    free(err);
>      err2 = xenbus_unwatch_path_token(XBT_NIL, path, path);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      snprintf(nodename, sizeof(nodename), "%s/info-ref", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>      snprintf(nodename, sizeof(nodename), "%s/event-channel", dev->nodename);
>      err2 = xenbus_rm(XBT_NIL, nodename);
> -    if (err2) free(err2);
> +    free(err2);
>  
>      if (!err)
>          free_pcifront(dev);
> diff --git a/tools/blktap/drivers/blktapctrl.c 
> b/tools/blktap/drivers/blktapctrl.c
> index 0a8b880..0022264 100644
> --- a/tools/blktap/drivers/blktapctrl.c
> +++ b/tools/blktap/drivers/blktapctrl.c
> @@ -642,11 +642,9 @@ static int connect_tapdisk(blkif_t *blkif, int minor)
>       ret = 0;
>       
>  fail:
> -     if (rdctldev)
> -             free(rdctldev);
> +     free(rdctldev);
>  
> -     if (wrctldev)
> -             free(wrctldev);
> +     free(wrctldev);
>  
>       return ret;
>  }
> diff --git a/tools/blktap/drivers/tapaio.c b/tools/blktap/drivers/tapaio.c
> index 140c44a..ae26577 100644
> --- a/tools/blktap/drivers/tapaio.c
> +++ b/tools/blktap/drivers/tapaio.c
> @@ -244,18 +244,12 @@ fail:
>  
>  void tap_aio_free(tap_aio_context_t *ctx)
>  {
> -     if (ctx->sector_lock)
> -             free(ctx->sector_lock);
> -     if (ctx->iocb_list)
> -             free(ctx->iocb_list);
> -     if (ctx->pending_aio)
> -             free(ctx->pending_aio);
> -     if (ctx->aio_events)
> -             free(ctx->aio_events);
> -     if (ctx->iocb_free)
> -             free(ctx->iocb_free);
> -     if (ctx->iocb_queue)
> -             free(ctx->iocb_queue);
> +     free(ctx->sector_lock);
> +     free(ctx->iocb_list);
> +     free(ctx->pending_aio);
> +     free(ctx->aio_events);
> +     free(ctx->iocb_free);
> +     free(ctx->iocb_queue);
>  }
>  
>  /*TODO: Fix sector span!*/
> diff --git a/tools/blktap/drivers/tapdisk.c b/tools/blktap/drivers/tapdisk.c
> index 19cd777..a6e8a7c 100644
> --- a/tools/blktap/drivers/tapdisk.c
> +++ b/tools/blktap/drivers/tapdisk.c
> @@ -82,10 +82,8 @@ static void daemonize(void)
>  
>  static void free_driver(struct disk_driver *d)
>  {
> -     if (d->name)
> -             free(d->name);
> -     if (d->private)
> -             free(d->private);
> +     free(d->name);
> +     free(d->private);
>       free(d);
>  }
>  
> @@ -354,8 +352,7 @@ static int open_disk(struct td_state *s,
>  
>   fail:
>       DPRINTF("failed opening disk\n");
> -     if (id.name)
> -             free(id.name);
> +     free(id.name);
>       d = s->disks;
>       while (d) {
>               struct disk_driver *tmp = d->next;
> diff --git a/tools/blktap/lib/xenbus.c b/tools/blktap/lib/xenbus.c
> index 948eb02..9edbf5a 100644
> --- a/tools/blktap/lib/xenbus.c
> +++ b/tools/blktap/lib/xenbus.c
> @@ -160,10 +160,8 @@ static int backend_remove(struct xs_handle *h, struct 
> backend_info *be)
>               DPRINTF("Freeing blkif dev [%d]\n",be->blkif->devnum);
>               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;
>  }
> @@ -435,8 +433,7 @@ fail:
>               backend_remove(h, be);
>       }
>  close:
> -     if (path)
> -             free(path);
> +     free(path);
>       return;
>  }
>  
> @@ -501,8 +498,7 @@ static void ueblktap_probe(struct xs_handle *h, struct 
> xenbus_watch *w,
>               if ( (be != NULL) && (be->blkif != NULL) ) 
>                       backend_remove(h, be);
>               else goto free_be;
> -             if (bepath)
> -                     free(bepath);
> +             free(bepath);
>               return;
>       }
>       
> @@ -522,12 +518,9 @@ static void ueblktap_probe(struct xs_handle *h, struct 
> xenbus_watch *w,
>       return;
>       
>   free_be:
> -     if (frontend)
> -             free(frontend);
> -     if (bepath)
> -             free(bepath);
> -     if (be) 
> -             free(be);
> +     free(frontend);
> +     free(bepath);
> +     free(be);
>  }
>  
>  /**
> diff --git a/tools/blktap/lib/xs_api.c b/tools/blktap/lib/xs_api.c
> index 4648432..1624cb9 100644
> --- a/tools/blktap/lib/xs_api.c
> +++ b/tools/blktap/lib/xs_api.c
> @@ -204,8 +204,7 @@ char *get_dom_domid(struct xs_handle *h)
>       }
>  done:
>       xs_transaction_end(h, xth, 0);
> -     if (e)
> -             free(e);
> +     free(e);
>       return domid;
>  }
>  
> diff --git a/tools/blktap2/control/tap-ctl-list.c 
> b/tools/blktap2/control/tap-ctl-list.c
> index c91f6f4..170735e 100644
> --- a/tools/blktap2/control/tap-ctl-list.c
> +++ b/tools/blktap2/control/tap-ctl-list.c
> @@ -219,8 +219,7 @@ out:
>       return err ? : n_minors;
>  
>  fail:
> -     if (minorv)
> -             free(minorv);
> +     free(minorv);
>  
>       goto out;
>  }
> @@ -302,8 +301,7 @@ out:
>       return err ? : n_taps;
>  
>  fail:
> -     if (tapv)
> -             free(tapv);
> +     free(tapv);
>  
>       goto out;
>  }
> diff --git a/tools/blktap2/drivers/block-log.c 
> b/tools/blktap2/drivers/block-log.c
> index 5330cdc..21c1946 100644
> --- a/tools/blktap2/drivers/block-log.c
> +++ b/tools/blktap2/drivers/block-log.c
> @@ -110,8 +110,7 @@ static int writelog_create(struct tdlog_state *s)
>  
>  static int writelog_free(struct tdlog_state *s)
>  {
> -  if (s->writelog)
> -    free(s->writelog);
> +  free(s->writelog);
>  
>    return 0;
>  }
> diff --git a/tools/flask/utils/loadpolicy.c b/tools/flask/utils/loadpolicy.c
> index f347b97..2edcf97 100644
> --- a/tools/flask/utils/loadpolicy.c
> +++ b/tools/flask/utils/loadpolicy.c
> @@ -108,8 +108,7 @@ int main (int argCnt, const char *args[])
>      }
>  
>  done:
> -    if ( polMemCp )
> -        free(polMemCp);
> +    free(polMemCp);
>      if ( polMem )
>      {
>          ret = munmap(polMem, info.st_size);
> diff --git a/tools/libxc/xc_compression.c b/tools/libxc/xc_compression.c
> index 89f1be7..8f0b89d 100644
> --- a/tools/libxc/xc_compression.c
> +++ b/tools/libxc/xc_compression.c
> @@ -457,16 +457,11 @@ void xc_compression_free_context(xc_interface *xch, 
> comp_ctx *ctx)
>  {
>      if (!ctx) return;
>  
> -    if (ctx->inputbuf)
> -        free(ctx->inputbuf);
> -    if (ctx->sendbuf_pfns)
> -        free(ctx->sendbuf_pfns);
> -    if (ctx->cache_base)
> -        free(ctx->cache_base);
> -    if (ctx->pfn2cache)
> -        free(ctx->pfn2cache);
> -    if (ctx->cache)
> -        free(ctx->cache);
> +    free(ctx->inputbuf);
> +    free(ctx->sendbuf_pfns);
> +    free(ctx->cache_base);
> +    free(ctx->pfn2cache);
> +    free(ctx->cache);
>      free(ctx);
>  }
>  
> diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c
> index a9681f7..e328dcf 100644
> --- a/tools/libxc/xc_core_x86.c
> +++ b/tools/libxc/xc_core_x86.c
> @@ -180,11 +180,9 @@ out:
>      if ( live_p2m_frame_list )
>          munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
>  
> -    if ( p2m_frame_list_list )
> -        free(p2m_frame_list_list);
> +    free(p2m_frame_list_list);
>  
> -    if ( p2m_frame_list )
> -        free(p2m_frame_list);
> +    free(p2m_frame_list);
>  
>      errno = err;
>      return ret;
> diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
> index fbc15e9..673d1e9 100644
> --- a/tools/libxc/xc_domain_save.c
> +++ b/tools/libxc/xc_domain_save.c
> @@ -773,11 +773,9 @@ static xen_pfn_t *map_and_save_p2m_table(xc_interface 
> *xch,
>      if ( live_p2m_frame_list )
>          munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
>  
> -    if ( p2m_frame_list_list ) 
> -        free(p2m_frame_list_list);
> +    free(p2m_frame_list_list);
>  
> -    if ( p2m_frame_list ) 
> -        free(p2m_frame_list);
> +    free(p2m_frame_list);
>  
>      return success ? p2m : NULL;
>  }
> diff --git a/tools/libxc/xc_gnttab.c b/tools/libxc/xc_gnttab.c
> index a8cc381..79dab40 100644
> --- a/tools/libxc/xc_gnttab.c
> +++ b/tools/libxc/xc_gnttab.c
> @@ -124,8 +124,7 @@ static void *_gnttab_map_table(xc_interface *xch, int 
> domid, int *gnt_num)
>  err:
>      if ( frame_list )
>          xc_hypercall_buffer_free(xch, frame_list);
> -    if ( pfn_list )
> -        free(pfn_list);
> +    free(pfn_list);
>  
>      return gnt;
>  }
> diff --git a/tools/libxc/xc_offline_page.c b/tools/libxc/xc_offline_page.c
> index 8195efb..0b4cdf9 100644
> --- a/tools/libxc/xc_offline_page.c
> +++ b/tools/libxc/xc_offline_page.c
> @@ -626,14 +626,11 @@ failed:
>          }
>      }
>  
> -    if (mmu)
> -        free(mmu);
> +    free(mmu);
>  
> -    if (old_ptes.entries)
> -        free(old_ptes.entries);
> +    free(old_ptes.entries);
>  
> -    if (backup)
> -        free(backup);
> +    free(backup);
>  
>      if (gnttab_v1)
>          munmap(gnttab_v1, gnt_num / (PAGE_SIZE/sizeof(grant_entry_v1_t)));
> diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> index fd2f280..73b7e63 100644
> --- a/tools/libxl/libxl_event.c
> +++ b/tools/libxl/libxl_event.c
> @@ -578,8 +578,7 @@ int libxl__ev_xswatch_register(libxl__gc *gc, 
> libxl__ev_xswatch *w,
>   out_rc:
>      if (use)
>          LIBXL_SLIST_INSERT_HEAD(&CTX->watch_freeslots, use, empty);
> -    if (path_copy)
> -        free(path_copy);
> +    free(path_copy);
>      CTX_UNLOCK;
>      return rc;
>  }
> diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
> index f681f3a..7e825ee 100644
> --- a/tools/libxl/libxl_qmp.c
> +++ b/tools/libxl/libxl_qmp.c
> @@ -406,12 +406,10 @@ static void qmp_close(libxl__qmp_handler *qmp)
>  
>      close(qmp->qmp_fd);
>      LIBXL_STAILQ_FOREACH(pp, &qmp->callback_list, next) {
> -        if (tmp)
> -            free(tmp);
> +        free(tmp);
>          tmp = pp;
>      }
> -    if (tmp)
> -        free(tmp);
> +    free(tmp);
>  }
>  
>  static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
> diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
> index 8e567a8..664a730 100644
> --- a/tools/libxl/libxl_utils.c
> +++ b/tools/libxl/libxl_utils.c
> @@ -355,7 +355,7 @@ int libxl_read_file_contents(libxl_ctx *ctx, const char 
> *filename,
>      e = errno;
>      assert(e != ENOENT);
>      if (f) fclose(f);
> -    if (data) free(data);
> +    free(data);
>      return e;
>  }
>  
> diff --git a/tools/memshr/bidir-hash.c b/tools/memshr/bidir-hash.c
> index bed8179..3d34637 100644
> --- a/tools/memshr/bidir-hash.c
> +++ b/tools/memshr/bidir-hash.c
> @@ -208,8 +208,8 @@ static void free_buckets(struct __hash *h,
>                           struct bucket *buckets,
>                           struct bucket_lock *bucket_locks)
>  {
> -    if(buckets) free(buckets);
> -    if(bucket_locks) free(bucket_locks);
> +    free(buckets);
> +    free(bucket_locks);
>  }
>  
>  static int max_entries(struct __hash *h)
> diff --git a/tools/misc/gtraceview.c b/tools/misc/gtraceview.c
> index d8b4589..cf9287c 100644
> --- a/tools/misc/gtraceview.c
> +++ b/tools/misc/gtraceview.c
> @@ -959,8 +959,7 @@ int time_mode_rebuild(uint64_t start_time, uint64_t 
> time_scale)
>      state = malloc(sizeof(struct state) * number);
>      if (!state)
>          return 1;
> -    if (this->state)
> -        free(this->state);
> +    free(this->state);
>      this->state = state;
>      this->width = 9;
>      this->row = 0;
> diff --git a/tools/tests/xen-access/xen-access.c 
> b/tools/tests/xen-access/xen-access.c
> index 49195a8..b00c05a 100644
> --- a/tools/tests/xen-access/xen-access.c
> +++ b/tools/tests/xen-access/xen-access.c
> @@ -219,10 +219,8 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t 
> *xenaccess)
>      }
>      xenaccess->xc_handle = NULL;
>  
> -    if ( xenaccess->platform_info )
> -        free(xenaccess->platform_info);
> -    if ( xenaccess->domain_info )
> -        free(xenaccess->domain_info);
> +    free(xenaccess->platform_info);
> +    free(xenaccess->domain_info);
>      free(xenaccess);
>  
>      return 0;
> diff --git a/tools/xenbackendd/xenbackendd.c b/tools/xenbackendd/xenbackendd.c
> index 5381a2a..f1eb1f5 100644
> --- a/tools/xenbackendd/xenbackendd.c
> +++ b/tools/xenbackendd/xenbackendd.c
> @@ -291,8 +291,7 @@ main(int argc, char * const argv[])
>  
>               switch(type) {
>               case DEVTYPE_VIF:
> -                     if (s)
> -                             free(s);
> +                     free(s);
>                       snprintf(buf, sizeof(buf), "%s/script",
>                           vec[XS_WATCH_PATH]);
>                       s = xs_read(xs, XBT_NULL, buf, 0);
> @@ -314,8 +313,7 @@ main(int argc, char * const argv[])
>               }
>  
>  next2:
> -             if (s)
> -                     free(s);
> +             free(s);
>               free(sstate);
>  
>  next1:
> -- 
> 1.7.10.4
> 

-- 
Samuel
<y> update-menus: relocation error: update-menus: symbol 
_ZNSt9basic_iosIcSt11char_traitsIcEE4initEPSt15basic_streambufIcS1_E, version 
GLIBCPP_3.2 not defined in file libstdc++.so.5 with link time reference
<y> quoi que ça peut bien vouloir dire ?
<D> N a eu la meme merde
<y> c ça que ça veut dire ? wow, c'est bien crypté :)
 -+- #ens-mim s'entraide -+-

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.