diff mbox series

[1/8] tools/libxl: Simplify DOMCTL_CDF_ flags handling in libxl__domain_make()

Message ID 20200930134248.4918-2-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series x86: Untangle Nested virt and CPUID interactions | expand

Commit Message

Andrew Cooper Sept. 30, 2020, 1:42 p.m. UTC
The use of the ternary operator serves only to obfuscate the code.  Rewrite it
in more simple terms, avoiding the need to conditionally OR zero into the
flags.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Jackson <iwj@xenproject.org>
CC: Wei Liu <wl@xen.org>
CC: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_create.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Roger Pau Monné Oct. 1, 2020, 9:26 a.m. UTC | #1
On Wed, Sep 30, 2020 at 02:42:41PM +0100, Andrew Cooper wrote:
> The use of the ternary operator serves only to obfuscate the code.  Rewrite it
> in more simple terms, avoiding the need to conditionally OR zero into the
> flags.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Might be worth adding to the log that it's a non-functional change.

Thanks, Roger.
Wei Liu Oct. 1, 2020, 10:54 a.m. UTC | #2
On Wed, Sep 30, 2020 at 02:42:41PM +0100, Andrew Cooper wrote:
> The use of the ternary operator serves only to obfuscate the code.  Rewrite it
> in more simple terms, avoiding the need to conditionally OR zero into the
> flags.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Wei Liu <wl@xen.org>
diff mbox series

Patch

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1031b75159..ed671052d7 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -612,10 +612,12 @@  int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
 
         if (info->type != LIBXL_DOMAIN_TYPE_PV) {
             create.flags |= XEN_DOMCTL_CDF_hvm;
-            create.flags |=
-                libxl_defbool_val(info->hap) ? XEN_DOMCTL_CDF_hap : 0;
-            create.flags |=
-                libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off;
+
+            if ( libxl_defbool_val(info->hap) )
+                create.flags |= XEN_DOMCTL_CDF_hap;
+
+            if ( !libxl_defbool_val(info->oos) )
+                create.flags |= XEN_DOMCTL_CDF_oos_off;
         }
 
         assert(info->passthrough != LIBXL_PASSTHROUGH_DEFAULT);