From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH for-next v2 09/10] x86/domain: move PV specific code to pv/domain.c
Date: Wed, 26 Apr 2017 13:38:20 +0100 [thread overview]
Message-ID: <070bd720-9853-65bd-0c02-bf1af6b416c4@citrix.com> (raw)
In-Reply-To: <5900548B020000780015436A@prv-mh.provo.novell.com>
On 26/04/17 07:04, Jan Beulich wrote:
>>>> On 25.04.17 at 16:52, <andrew.cooper3@citrix.com> wrote:
>> On 25/04/17 14:52, Wei Liu wrote:
>>> +
>>> + for_each_vcpu( d, v )
>>> + {
>>> + rc = setup_compat_arg_xlat(v);
>>> + if ( !rc )
>>> + rc = setup_compat_l4(v);
>>> +
>>> + if ( rc )
>>> + goto undo_and_fail;
>> This is odd structuring. Care to rearrange it with two goto's, rather
>> than inverting the first rc check?
> I don't see anything odd about it - just like with preferably limiting
> the number of return statements, I think limiting the number of
> goto-s is quite desirable. What if the second if()'s body had more
> than just a goto? I'd certainly prefer the code structure above in
> that case over _adding_ a goto into this second if(). Further down
> the same two functions are being called, pointlessly using two
> goto-s. If you really wanted to get rid of the inverted first
> condition, then how about if ( (rc = ...) || (rc = ...) ) ?
For functions which have standard rc semantics, you can actually chain
them together like:
rc = setup_compat_arg_xlat(v) ?: setup_compat_l4(v) ?: ... ;
which will break at the first non-zero return in the chain, and allows
you to have a single assignment and single goto.
Whether this style is sensible to follow is a different matter, but it
certainly is compact.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-04-26 12:38 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 13:52 [PATCH for-next v2 00/10] x86: refactor x86/domain.c Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 01/10] x86/mm: make free_perdomain_mappings idempotent Wei Liu
2017-04-25 13:54 ` Andrew Cooper
2017-04-25 13:52 ` [PATCH for-next v2 02/10] x86/domain: provide pv_{create, destroy}_gdt_ldt_l1tab and use them Wei Liu
2017-04-25 13:56 ` Andrew Cooper
2017-04-25 14:02 ` Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 03/10] x86/domain: make release_compact_l4 NULL tolerant Wei Liu
2017-04-25 13:56 ` Andrew Cooper
2017-04-25 13:52 ` [PATCH for-next v2 04/10] x86/domain: factor out pv_vcpu_destroy Wei Liu
2017-04-25 13:58 ` Andrew Cooper
2017-04-26 12:21 ` Jan Beulich
2017-04-25 13:52 ` [PATCH for-next v2 05/10] x86/domain: factor out pv_vcpu_initialise Wei Liu
2017-04-25 14:08 ` Andrew Cooper
2017-04-25 14:27 ` Wei Liu
2017-04-26 12:25 ` Jan Beulich
2017-04-26 12:53 ` Wei Liu
2017-04-26 13:27 ` Jan Beulich
2017-04-26 13:35 ` Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 06/10] x86/domain: push some code down to hvm_domain_initialise Wei Liu
2017-04-25 14:15 ` Andrew Cooper
2017-04-25 14:29 ` Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 07/10] x86/domain: factor out pv_domain_destroy Wei Liu
2017-04-25 14:18 ` Andrew Cooper
2017-04-26 12:32 ` Jan Beulich
2017-04-26 12:56 ` Wei Liu
2017-04-26 13:29 ` Jan Beulich
2017-04-26 13:36 ` Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 08/10] x86/domain: factor out pv_domain_initialise Wei Liu
2017-04-25 14:30 ` Andrew Cooper
2017-04-25 13:52 ` [PATCH for-next v2 09/10] x86/domain: move PV specific code to pv/domain.c Wei Liu
2017-04-25 14:52 ` Andrew Cooper
2017-04-25 15:07 ` Wei Liu
2017-04-26 6:04 ` Jan Beulich
2017-04-26 12:38 ` Andrew Cooper [this message]
2017-04-26 12:39 ` Jan Beulich
2017-04-26 12:46 ` Andrew Cooper
2017-04-26 13:00 ` Wei Liu
2017-04-26 13:26 ` Jan Beulich
2017-04-26 13:32 ` Wei Liu
2017-04-26 14:12 ` Jan Beulich
2017-04-26 15:46 ` Wei Liu
2017-04-25 13:52 ` [PATCH for-next v2 10/10] x86/domain: move HVM specific code to hvm/domain.c Wei Liu
2017-04-25 14:56 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=070bd720-9853-65bd-0c02-bf1af6b416c4@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).