xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH v2] dom0-build: fix build with clang5
@ 2019-07-17  6:47 Jan Beulich
  2019-07-29 10:05 ` Julien Grall
  2019-12-20 16:26 ` [Xen-devel] Ping: " Jan Beulich
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Beulich @ 2019-07-17  6:47 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Wei Liu,
	Roger Pau Monné

With non-empty CONFIG_DOM0_MEM clang5 produces

dom0_build.c:344:24: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
     if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
                        ^  ~~~~~~~~~~~~~~~~~~
dom0_build.c:344:24: note: use '&' for a bitwise operation
     if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
                        ^~
                        &
dom0_build.c:344:24: note: remove constant to silence this warning
     if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
                       ~^~~~~~~~~~~~~~~~~~~~~
1 error generated.

Obviously neither of the two suggestions are an option here. Oddly
enough swapping the operands of the && helps, while e.g. casting or
parenthesizing doesn't. Another workable variant looks to be the use of
!! on the constant.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Also adjust the Arm incarnation of the same construct.
---
I'm open to going the !! or yet some different route (but not really the
suggested strlen() one). No matter which one we choose, I'm afraid it is
going to remain guesswork what newer (and future) versions of clang will
choke on.

--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2125,7 +2125,7 @@ int __init construct_dom0(struct domain
  
      printk("*** LOADING DOMAIN 0 ***\n");
  
-    if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
+    if ( CONFIG_DOM0_MEM[0] && !dom0_mem_set )
          parse_dom0_mem(CONFIG_DOM0_MEM);
  
      if ( dom0_mem <= 0 )
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -341,7 +341,7 @@ unsigned long __init dom0_compute_nr_pag
      unsigned long avail = 0, nr_pages, min_pages, max_pages;
      bool need_paging;
  
-    if ( !dom0_mem_set && CONFIG_DOM0_MEM[0] )
+    if ( CONFIG_DOM0_MEM[0] && !dom0_mem_set )
          parse_dom0_mem(CONFIG_DOM0_MEM);
  
      for_each_node_mask ( node, dom0_nodes )
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2020-01-15 10:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17  6:47 [Xen-devel] [PATCH v2] dom0-build: fix build with clang5 Jan Beulich
2019-07-29 10:05 ` Julien Grall
2019-07-29 11:36   ` Jan Beulich
2019-12-20 16:26 ` [Xen-devel] Ping: " Jan Beulich
2020-01-11 16:27   ` Julien Grall
2020-01-15  9:56   ` Roger Pau Monné
2020-01-15 10:00     ` Roger Pau Monné
2020-01-15 10:18       ` Jan Beulich

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).