qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warning
@ 2015-07-21 23:40 Michael Roth
  2015-09-02  6:24 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Roth @ 2015-07-21 23:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, qemu-ppc, agraf

Current code for generating DRC type mask generates the following warning with
clang -fsanitizer=undefined -fsanitizer=shift:

  runtime error: left shift of negative value -1

Fix this by calculating the mask like a sane person would.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/ppc/spapr_drc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index ee87432..0e7d725 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -32,7 +32,7 @@
 
 #define DRC_CONTAINER_PATH "/dr-connector"
 #define DRC_INDEX_TYPE_SHIFT 28
-#define DRC_INDEX_ID_MASK (~(~0 << DRC_INDEX_TYPE_SHIFT))
+#define DRC_INDEX_ID_MASK ((1 << DRC_INDEX_TYPE_SHIFT) - 1)
 
 static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type)
 {
-- 
1.9.1

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

* Re: [Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warning
  2015-07-21 23:40 [Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warning Michael Roth
@ 2015-09-02  6:24 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2015-09-02  6:24 UTC (permalink / raw)
  To: Michael Roth; +Cc: peter.maydell, qemu-ppc, qemu-devel, agraf

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

On Tue, Jul 21, 2015 at 06:40:16PM -0500, Michael Roth wrote:
> Current code for generating DRC type mask generates the following warning with
> clang -fsanitizer=undefined -fsanitizer=shift:
> 
>   runtime error: left shift of negative value -1
> 
> Fix this by calculating the mask like a sane person would.
> 
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Sorry I missed this before - please CC me on patches to the spapr
code.  I actually already wrote an equivalent patch and put it in
spapr-next.


> ---
>  hw/ppc/spapr_drc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index ee87432..0e7d725 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -32,7 +32,7 @@
>  
>  #define DRC_CONTAINER_PATH "/dr-connector"
>  #define DRC_INDEX_TYPE_SHIFT 28
> -#define DRC_INDEX_ID_MASK (~(~0 << DRC_INDEX_TYPE_SHIFT))
> +#define DRC_INDEX_ID_MASK ((1 << DRC_INDEX_TYPE_SHIFT) - 1)
>  
>  static sPAPRDRConnectorTypeShift get_type_shift(sPAPRDRConnectorType type)
>  {

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-09-02  7:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-21 23:40 [Qemu-devel] [PATCH for-2.4] spapr_drc: fix clang -fsanitizer=shift warning Michael Roth
2015-09-02  6:24 ` David Gibson

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