From: "Jan Beulich" Subject: libxc: domain restore: fold redundant variables Date: Mon, 24 Mar 2014 12:14:05 +0000 Message-ID: <53302F9D020000780000154B@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB785D99D.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WS3la-000070-HQ for xen-devel@lists.xenproject.org; Mon, 24 Mar 2014 12:14:10 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Ian Campbell , Ian Jackson List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB785D99D.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline "vcpuextstate_size" being non-zero fully expresses "vcpuextstate" being true - drop the latter. Signed-off-by: Jan Beulich --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -248,7 +248,7 @@ static int uncanonicalize_pagetable( static xen_pfn_t *load_p2m_frame_list( xc_interface *xch, struct restore_ctx *ctx, int io_fd, int *pae_extended_cr3, int *ext_vcpucontext, - int *vcpuextstate, uint32_t *vcpuextstate_size) + uint32_t *vcpuextstate_size) { xen_pfn_t *p2m_frame_list; vcpu_guest_context_any_t ctxt; @@ -326,7 +326,6 @@ static xen_pfn_t *load_p2m_frame_list( } else if ( !strncmp(chunk_sig, "xcnt", 4) ) { - *vcpuextstate =3D 1; if ( RDEXACT(io_fd, vcpuextstate_size, sizeof(*vcpuextstat= e_size)) ) { PERROR("read extended vcpu state size failed"); @@ -520,7 +519,7 @@ static int buffer_tail_hvm(xc_interface=20 struct tailbuf_hvm *buf, int fd, unsigned int max_vcpu_id, uint64_t *vcpumap, int ext_vcpucontext, - int vcpuextstate, uint32_t vcpuextstate_size) + uint32_t vcpuextstate_size) { uint8_t *tmp; unsigned char qemusig[21]; @@ -588,7 +587,6 @@ static int buffer_tail_pv(xc_interface * struct tailbuf_pv *buf, int fd, unsigned int max_vcpu_id, uint64_t *vcpumap, int ext_vcpucontext, - int vcpuextstate, uint32_t vcpuextstate_size) { unsigned int i; @@ -629,9 +627,7 @@ static int buffer_tail_pv(xc_interface * : sizeof(vcpu_guest_context_x86_32_t)) * buf->vcpucount; if ( ext_vcpucontext ) vcpulen +=3D 128 * buf->vcpucount; - if ( vcpuextstate ) { - vcpulen +=3D vcpuextstate_size * buf->vcpucount; - } + vcpulen +=3D vcpuextstate_size * buf->vcpucount; =20 if ( !(buf->vcpubuf) ) { if ( !(buf->vcpubuf =3D malloc(vcpulen)) ) { @@ -671,16 +667,14 @@ static int buffer_tail_pv(xc_interface * static int buffer_tail(xc_interface *xch, struct restore_ctx *ctx, tailbuf_t *buf, int fd, unsigned int max_vcpu_id, uint64_t *vcpumap, int ext_vcpucontext, - int vcpuextstate, uint32_t vcpuextstate_size) + uint32_t vcpuextstate_size) { if ( buf->ishvm ) return buffer_tail_hvm(xch, ctx, &buf->u.hvm, fd, max_vcpu_id, = vcpumap, - ext_vcpucontext, vcpuextstate, - vcpuextstate_size); + ext_vcpucontext, vcpuextstate_size); else return buffer_tail_pv(xch, ctx, &buf->u.pv, fd, max_vcpu_id, = vcpumap, - ext_vcpucontext, vcpuextstate, - vcpuextstate_size); + ext_vcpucontext, vcpuextstate_size); } =20 static void tailbuf_free_hvm(struct tailbuf_hvm *buf) @@ -1421,7 +1415,6 @@ int xc_domain_restore(xc_interface *xch, DECLARE_DOMCTL; xc_dominfo_t info; int rc =3D 1, frc, i, j, n, m, pae_extended_cr3 =3D 0, ext_vcpucontext= =3D 0; - int vcpuextstate =3D 0; uint32_t vcpuextstate_size =3D 0; unsigned long mfn, pfn; int nraces =3D 0; @@ -1527,7 +1520,7 @@ int xc_domain_restore(xc_interface *xch, /* Load the p2m frame list, plus potential extended info chunk */ p2m_frame_list =3D load_p2m_frame_list(xch, ctx, io_fd, &pae_extended_cr3, &ext_vcpucontext, - &vcpuextstate, &vcpuextstate_size); + &vcpuextstate_size); =20 if ( !p2m_frame_list ) goto out; @@ -1730,7 +1723,7 @@ int xc_domain_restore(xc_interface *xch, if ( !ctx->completed ) { =20 if ( buffer_tail(xch, ctx, &tailbuf, io_fd, max_vcpu_id, vcpumap, - ext_vcpucontext, vcpuextstate, vcpuextstate_size)= < 0 ) { + ext_vcpucontext, vcpuextstate_size) < 0 ) { ERROR ("error buffering image tail"); goto out; } @@ -1783,7 +1776,7 @@ int xc_domain_restore(xc_interface *xch, memset(&tmptail, 0, sizeof(tmptail)); tmptail.ishvm =3D hvm; if ( buffer_tail(xch, ctx, &tmptail, io_fd, max_vcpu_id, vcpumap, - ext_vcpucontext, vcpuextstate, vcpuextstate_size) < = 0 ) { + ext_vcpucontext, vcpuextstate_size) < 0 ) { ERROR ("error buffering image tail, finishing"); goto out; } @@ -2147,7 +2140,7 @@ int xc_domain_restore(xc_interface *xch, } =20 vcpu_ext_state_restore: - if ( !vcpuextstate ) + if ( !vcpuextstate_size ) continue; =20 memcpy(&domctl.u.vcpuextstate.xfeature_mask, vcpup, --=__PartB785D99D.1__= Content-Type: text/plain; name="libxc-domain-restore-vcpuextstate.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="libxc-domain-restore-vcpuextstate.patch" libxc: domain restore: fold redundant variables=0A=0A"vcpuextstate_size" = being non-zero fully expresses "vcpuextstate" being=0Atrue - drop the = latter.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/tools/libxc/xc_domain_restore.c=0A+++ b/tools/libxc/xc_domain_restore.c= =0A@@ -248,7 +248,7 @@ static int uncanonicalize_pagetable(=0A static = xen_pfn_t *load_p2m_frame_list(=0A xc_interface *xch, struct restore_ct= x *ctx,=0A int io_fd, int *pae_extended_cr3, int *ext_vcpucontext,=0A- = int *vcpuextstate, uint32_t *vcpuextstate_size)=0A+ uint32_t = *vcpuextstate_size)=0A {=0A xen_pfn_t *p2m_frame_list;=0A = vcpu_guest_context_any_t ctxt;=0A@@ -326,7 +326,6 @@ static xen_pfn_t = *load_p2m_frame_list(=0A }=0A else if ( !strncmp(ch= unk_sig, "xcnt", 4) )=0A {=0A- *vcpuextstate = =3D 1;=0A if ( RDEXACT(io_fd, vcpuextstate_size, sizeof(*vc= puextstate_size)) )=0A {=0A PERROR("rea= d extended vcpu state size failed");=0A@@ -520,7 +519,7 @@ static int = buffer_tail_hvm(xc_interface =0A struct = tailbuf_hvm *buf, int fd,=0A unsigned int = max_vcpu_id, uint64_t *vcpumap,=0A int = ext_vcpucontext,=0A- int vcpuextstate, uint32_t = vcpuextstate_size)=0A+ uint32_t vcpuextstate_size= )=0A {=0A uint8_t *tmp;=0A unsigned char qemusig[21];=0A@@ -588,7 = +587,6 @@ static int buffer_tail_pv(xc_interface *=0A = struct tailbuf_pv *buf, int fd,=0A unsigned = int max_vcpu_id, uint64_t *vcpumap,=0A int = ext_vcpucontext,=0A- int vcpuextstate,=0A = uint32_t vcpuextstate_size)=0A {=0A unsigned int = i;=0A@@ -629,9 +627,7 @@ static int buffer_tail_pv(xc_interface *=0A = : sizeof(vcpu_guest_context_x86_32_t)) * buf->vcpucount;=0A = if ( ext_vcpucontext )=0A vcpulen +=3D 128 * buf->vcpucount;=0A- = if ( vcpuextstate ) {=0A- vcpulen +=3D vcpuextstate_size * = buf->vcpucount;=0A- }=0A+ vcpulen +=3D vcpuextstate_size * buf->vcpuc= ount;=0A =0A if ( !(buf->vcpubuf) ) {=0A if ( !(buf->vcpubuf = =3D malloc(vcpulen)) ) {=0A@@ -671,16 +667,14 @@ static int buffer_tail_pv(= xc_interface *=0A static int buffer_tail(xc_interface *xch, struct = restore_ctx *ctx,=0A tailbuf_t *buf, int fd, = unsigned int max_vcpu_id,=0A uint64_t *vcpumap, int = ext_vcpucontext,=0A- int vcpuextstate, uint32_t = vcpuextstate_size)=0A+ uint32_t vcpuextstate_size)=0A= {=0A if ( buf->ishvm )=0A return buffer_tail_hvm(xch, ctx, = &buf->u.hvm, fd, max_vcpu_id, vcpumap,=0A- = ext_vcpucontext, vcpuextstate,=0A- vcpuextsta= te_size);=0A+ ext_vcpucontext, vcpuextstate_s= ize);=0A else=0A return buffer_tail_pv(xch, ctx, &buf->u.pv, = fd, max_vcpu_id, vcpumap,=0A- ext_vcpucontext,= vcpuextstate,=0A- vcpuextstate_size);=0A+ = ext_vcpucontext, vcpuextstate_size);=0A }=0A =0A = static void tailbuf_free_hvm(struct tailbuf_hvm *buf)=0A@@ -1421,7 +1415,6 = @@ int xc_domain_restore(xc_interface *xch,=0A DECLARE_DOMCTL;=0A = xc_dominfo_t info;=0A int rc =3D 1, frc, i, j, n, m, pae_extended_cr3 = =3D 0, ext_vcpucontext =3D 0;=0A- int vcpuextstate =3D 0;=0A = uint32_t vcpuextstate_size =3D 0;=0A unsigned long mfn, pfn;=0A = int nraces =3D 0;=0A@@ -1527,7 +1520,7 @@ int xc_domain_restore(xc_interfac= e *xch,=0A /* Load the p2m frame list, plus potential extended = info chunk */=0A p2m_frame_list =3D load_p2m_frame_list(xch, = ctx,=0A io_fd, &pae_extended_cr3, &ext_vcpucontext,=0A- = &vcpuextstate, &vcpuextstate_size);=0A+ &vcpuextstate_size);= =0A =0A if ( !p2m_frame_list )=0A goto out;=0A@@ = -1730,7 +1723,7 @@ int xc_domain_restore(xc_interface *xch,=0A if ( = !ctx->completed ) {=0A =0A if ( buffer_tail(xch, ctx, &tailbuf, = io_fd, max_vcpu_id, vcpumap,=0A- ext_vcpucontext, = vcpuextstate, vcpuextstate_size) < 0 ) {=0A+ = ext_vcpucontext, vcpuextstate_size) < 0 ) {=0A ERROR ("error = buffering image tail");=0A goto out;=0A }=0A@@ -1783,7 = +1776,7 @@ int xc_domain_restore(xc_interface *xch,=0A memset(&tmptail,= 0, sizeof(tmptail));=0A tmptail.ishvm =3D hvm;=0A if ( buffer_tail= (xch, ctx, &tmptail, io_fd, max_vcpu_id, vcpumap,=0A- = ext_vcpucontext, vcpuextstate, vcpuextstate_size) < 0 ) {=0A+ = ext_vcpucontext, vcpuextstate_size) < 0 ) {=0A ERROR = ("error buffering image tail, finishing");=0A goto out;=0A = }=0A@@ -2147,7 +2140,7 @@ int xc_domain_restore(xc_interface *xch,=0A = }=0A =0A vcpu_ext_state_restore:=0A- if ( !vcpuextstate )=0A+ = if ( !vcpuextstate_size )=0A continue;=0A =0A = memcpy(&domctl.u.vcpuextstate.xfeature_mask, vcpup,=0A --=__PartB785D99D.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB785D99D.1__=--