xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] tools/libxc: Adjust error handling in map_p2m_list() to fix CentOS 7 build
@ 2016-01-08 14:38 Andrew Cooper
  2016-01-08 14:43 ` Juergen Gross
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cooper @ 2016-01-08 14:38 UTC (permalink / raw)
  To: Xen-devel
  Cc: Juergen Gross, Andrew Cooper, Ian Jackson, Ian Campbell, Wei Liu

The "goto err;" for malloc() error handling would cause the cleanup code
to use 'ptes' before it had been initialised, and causing a build
failure because of -Werror=maybe-uninitialised.

Use "goto err;" consistently for all error handling.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Juergen Gross <jgross@suse.com>
---
 tools/libxc/xc_sr_save_x86_pv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
index 4deb58f..4a29460 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -316,8 +316,8 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
     xc_interface *xch = ctx->xch;
     xen_vaddr_t p2m_vaddr, p2m_end, mask, off;
     xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn;
-    uint64_t *ptes;
-    xen_pfn_t *mfns;
+    uint64_t *ptes = NULL;
+    xen_pfn_t *mfns = NULL;
     unsigned fpp, n_pages, level, shift, idx_start, idx_end, idx, saved_idx;
     int rc = -1;
 
@@ -327,7 +327,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
     {
         ERROR("Bad p2m_cr3 value %#" PRIx64, p2m_cr3);
         errno = ERANGE;
-        return -1;
+        goto err;
     }
 
     get_p2m_generation(ctx);
@@ -350,7 +350,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
             ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64,
                   p2m_vaddr, p2m_end);
             errno = ERANGE;
-            return -1;
+            goto err;
         }
     }
     else
@@ -363,7 +363,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
             ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64,
                   p2m_vaddr, p2m_end);
             errno = ERANGE;
-            return -1;
+            goto err;
         }
     }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tools/libxc: Adjust error handling in map_p2m_list() to fix CentOS 7 build
  2016-01-08 14:38 [PATCH v2] tools/libxc: Adjust error handling in map_p2m_list() to fix CentOS 7 build Andrew Cooper
@ 2016-01-08 14:43 ` Juergen Gross
  2016-01-08 15:32   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2016-01-08 14:43 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel; +Cc: Wei Liu, Ian Jackson, Ian Campbell

On 08/01/16 15:38, Andrew Cooper wrote:
> The "goto err;" for malloc() error handling would cause the cleanup code
> to use 'ptes' before it had been initialised, and causing a build
> failure because of -Werror=maybe-uninitialised.
> 
> Use "goto err;" consistently for all error handling.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Juergen Gross <jgross@suse.com>

> ---
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Juergen Gross <jgross@suse.com>
> ---
>  tools/libxc/xc_sr_save_x86_pv.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
> index 4deb58f..4a29460 100644
> --- a/tools/libxc/xc_sr_save_x86_pv.c
> +++ b/tools/libxc/xc_sr_save_x86_pv.c
> @@ -316,8 +316,8 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
>      xc_interface *xch = ctx->xch;
>      xen_vaddr_t p2m_vaddr, p2m_end, mask, off;
>      xen_pfn_t p2m_mfn, mfn, saved_mfn, max_pfn;
> -    uint64_t *ptes;
> -    xen_pfn_t *mfns;
> +    uint64_t *ptes = NULL;
> +    xen_pfn_t *mfns = NULL;
>      unsigned fpp, n_pages, level, shift, idx_start, idx_end, idx, saved_idx;
>      int rc = -1;
>  
> @@ -327,7 +327,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
>      {
>          ERROR("Bad p2m_cr3 value %#" PRIx64, p2m_cr3);
>          errno = ERANGE;
> -        return -1;
> +        goto err;
>      }
>  
>      get_p2m_generation(ctx);
> @@ -350,7 +350,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
>              ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64,
>                    p2m_vaddr, p2m_end);
>              errno = ERANGE;
> -            return -1;
> +            goto err;
>          }
>      }
>      else
> @@ -363,7 +363,7 @@ static int map_p2m_list(struct xc_sr_context *ctx, uint64_t p2m_cr3)
>              ERROR("Bad virtual p2m address range %#" PRIx64 "-%#" PRIx64,
>                    p2m_vaddr, p2m_end);
>              errno = ERANGE;
> -            return -1;
> +            goto err;
>          }
>      }
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tools/libxc: Adjust error handling in map_p2m_list() to fix CentOS 7 build
  2016-01-08 14:43 ` Juergen Gross
@ 2016-01-08 15:32   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2016-01-08 15:32 UTC (permalink / raw)
  To: Juergen Gross, Andrew Cooper, Xen-devel; +Cc: Ian Jackson, Wei Liu

On Fri, 2016-01-08 at 15:43 +0100, Juergen Gross wrote:
> On 08/01/16 15:38, Andrew Cooper wrote:
> > The "goto err;" for malloc() error handling would cause the cleanup
> > code
> > to use 'ptes' before it had been initialised, and causing a build
> > failure because of -Werror=maybe-uninitialised.
> > 
> > Use "goto err;" consistently for all error handling.
> > 
> > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> 
> Reviewed-by: Juergen Gross <jgross@suse.com>

Acked, applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-08 15:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-08 14:38 [PATCH v2] tools/libxc: Adjust error handling in map_p2m_list() to fix CentOS 7 build Andrew Cooper
2016-01-08 14:43 ` Juergen Gross
2016-01-08 15:32   ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).