All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniele Buono <dbuono@linux.vnet.ibm.com>
To: dbuono@linux.vnet.ibm.com, qemu-devel@nongnu.org
Cc: Thomas Huth <thuth@redhat.com>,
	David Hildenbrand <david@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	"open list:S390 KVM CPUs" <qemu-s390x@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: [PATCH v3 2/9] s390x: fix clang 11 warnings in cpu_models.c
Date: Thu,  5 Nov 2020 17:18:58 -0500	[thread overview]
Message-ID: <20201105221905.1350-3-dbuono@linux.vnet.ibm.com> (raw)
In-Reply-To: <20201105221905.1350-1-dbuono@linux.vnet.ibm.com>

There are void * pointers that get casted to enums, in cpu_models.c
Such casts can result in a small integer type and are caught as
warnings with clang, starting with version 11:

Clang 11 finds a bunch of spots in the code that trigger this new warnings:

../qemu-base/target/s390x/cpu_models.c:985:21: error: cast to smaller integer type 'S390Feat' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
    S390Feat feat = (S390Feat) opaque;
                    ^~~~~~~~~~~~~~~~~
../qemu-base/target/s390x/cpu_models.c:1002:21: error: cast to smaller integer type 'S390Feat' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
    S390Feat feat = (S390Feat) opaque;
                    ^~~~~~~~~~~~~~~~~
../qemu-base/target/s390x/cpu_models.c:1036:27: error: cast to smaller integer type 'S390FeatGroup' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
    S390FeatGroup group = (S390FeatGroup) opaque;
                          ^~~~~~~~~~~~~~~~~~~~~~
../qemu-base/target/s390x/cpu_models.c:1057:27: error: cast to smaller integer type 'S390FeatGroup' from 'void *' [-Werror,-Wvoid-pointer-to-enum-cast]
    S390FeatGroup group = (S390FeatGroup) opaque;
                          ^~~~~~~~~~~~~~~~~~~~~~
4 errors generated.

Avoid this warning by casting the pointer to uintptr_t first.

Signed-off-by: Daniele Buono <dbuono@linux.vnet.ibm.com>
---
 target/s390x/cpu_models.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 461e0b8f4a..b5abff8bef 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -986,7 +986,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)
 static void get_feature(Object *obj, Visitor *v, const char *name,
                         void *opaque, Error **errp)
 {
-    S390Feat feat = (S390Feat) opaque;
+    S390Feat feat = (S390Feat) (uintptr_t) opaque;
     S390CPU *cpu = S390_CPU(obj);
     bool value;
 
@@ -1003,7 +1003,7 @@ static void get_feature(Object *obj, Visitor *v, const char *name,
 static void set_feature(Object *obj, Visitor *v, const char *name,
                         void *opaque, Error **errp)
 {
-    S390Feat feat = (S390Feat) opaque;
+    S390Feat feat = (S390Feat) (uintptr_t) opaque;
     DeviceState *dev = DEVICE(obj);
     S390CPU *cpu = S390_CPU(obj);
     bool value;
@@ -1037,7 +1037,7 @@ static void set_feature(Object *obj, Visitor *v, const char *name,
 static void get_feature_group(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
-    S390FeatGroup group = (S390FeatGroup) opaque;
+    S390FeatGroup group = (S390FeatGroup) (uintptr_t) opaque;
     const S390FeatGroupDef *def = s390_feat_group_def(group);
     S390CPU *cpu = S390_CPU(obj);
     S390FeatBitmap tmp;
@@ -1058,7 +1058,7 @@ static void get_feature_group(Object *obj, Visitor *v, const char *name,
 static void set_feature_group(Object *obj, Visitor *v, const char *name,
                               void *opaque, Error **errp)
 {
-    S390FeatGroup group = (S390FeatGroup) opaque;
+    S390FeatGroup group = (S390FeatGroup) (uintptr_t) opaque;
     const S390FeatGroupDef *def = s390_feat_group_def(group);
     DeviceState *dev = DEVICE(obj);
     S390CPU *cpu = S390_CPU(obj);
-- 
2.17.1



  parent reply	other threads:[~2020-11-05 22:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 22:18 [PATCH v3 0/9] Add support for Control-Flow Integrity Daniele Buono
2020-11-05 22:18 ` [PATCH v3 1/9] fuzz: Make fork_fuzz.ld compatible with LLVM's LLD Daniele Buono
2020-11-06 14:50   ` Alexander Bulekov
2020-11-19 22:06     ` Daniele Buono
2020-12-13  2:51       ` Alexander Bulekov
2020-11-05 22:18 ` Daniele Buono [this message]
2020-11-09 11:12   ` [PATCH v3 2/9] s390x: fix clang 11 warnings in cpu_models.c Cornelia Huck
2020-11-05 22:18 ` [PATCH v3 3/9] hw/usb: reorder fields in UASStatus Daniele Buono
2020-11-06 14:28   ` [PATCH-for-5.2? " Philippe Mathieu-Daudé
2020-11-19 16:16     ` Daniele Buono
2021-01-14  8:17       ` Marc-André Lureau
2021-01-14 19:33         ` Daniele Buono
2021-01-18 11:38       ` Philippe Mathieu-Daudé
2021-01-18 16:09         ` Gerd Hoffmann
2020-11-05 22:19 ` [PATCH v3 4/9] s390x: Avoid variable size warning in ipl.h Daniele Buono
2020-11-09 11:14   ` Cornelia Huck
2020-11-05 22:19 ` [PATCH v3 5/9] scsi: fix overflow in scsi_disk_new_request_dump Daniele Buono
2020-11-06 14:32   ` [PATCH-for-5.2? " Philippe Mathieu-Daudé
2020-11-06 14:43     ` Philippe Mathieu-Daudé
2020-11-09 13:26       ` Philippe Mathieu-Daudé
2020-11-19 16:44         ` Daniele Buono
2020-11-05 22:19 ` [PATCH v3 6/9] configure,meson: add option to enable LTO Daniele Buono
2020-11-05 22:19 ` [PATCH v3 7/9] cfi: Initial support for cfi-icall in QEMU Daniele Buono
2020-11-05 22:19 ` [PATCH v3 8/9] check-block: enable iotests with cfi-icall Daniele Buono
2020-11-05 22:19 ` [PATCH v3 9/9] configure,meson: support Control-Flow Integrity Daniele Buono
2020-11-06 12:47 ` [PATCH v3 0/9] Add support for " Cornelia Huck
2020-11-06 13:35   ` Daniele Buono
2020-11-06 14:58     ` Alexander Bulekov
2020-11-19 21:58       ` Daniele Buono

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=20201105221905.1350-3-dbuono@linux.vnet.ibm.com \
    --to=dbuono@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.