[PATCH 4/6] contrib/plugins/hotblocks: fix warning when compiling on 32bits host

Pierrick Bouvier posted 6 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH 4/6] contrib/plugins/hotblocks: fix warning when compiling on 32bits host
Posted by Pierrick Bouvier 3 months, 1 week ago
Found on debian stable (i386).

../contrib/plugins/hotblocks.c: In function 'vcpu_tb_trans':
../contrib/plugins/hotblocks.c:117:56: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  117 |     cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash);
      |                                                        ^
../contrib/plugins/hotblocks.c:126:40: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  126 |         g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt);
      |

Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
 contrib/plugins/hotblocks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
index 02bc5078bdd..d540f1b7f0b 100644
--- a/contrib/plugins/hotblocks.c
+++ b/contrib/plugins/hotblocks.c
@@ -109,9 +109,9 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 {
     ExecCount *cnt;
-    uint64_t pc = qemu_plugin_tb_vaddr(tb);
+    uintptr_t pc = qemu_plugin_tb_vaddr(tb);
     size_t insns = qemu_plugin_tb_n_insns(tb);
-    uint64_t hash = pc ^ insns;
+    uintptr_t hash = pc ^ insns;
 
     g_mutex_lock(&lock);
     cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash);
-- 
2.39.2
Re: [PATCH 4/6] contrib/plugins/hotblocks: fix warning when compiling on 32bits host
Posted by Thomas Huth 3 months, 1 week ago
On 15/08/2024 01.36, Pierrick Bouvier wrote:
> Found on debian stable (i386).
> 
> ../contrib/plugins/hotblocks.c: In function 'vcpu_tb_trans':
> ../contrib/plugins/hotblocks.c:117:56: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    117 |     cnt = (ExecCount *) g_hash_table_lookup(hotblocks, (gconstpointer) hash);
>        |                                                        ^
> ../contrib/plugins/hotblocks.c:126:40: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    126 |         g_hash_table_insert(hotblocks, (gpointer) hash, (gpointer) cnt);
>        |
> 
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
>   contrib/plugins/hotblocks.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c
> index 02bc5078bdd..d540f1b7f0b 100644
> --- a/contrib/plugins/hotblocks.c
> +++ b/contrib/plugins/hotblocks.c
> @@ -109,9 +109,9 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *udata)
>   static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
>   {
>       ExecCount *cnt;
> -    uint64_t pc = qemu_plugin_tb_vaddr(tb);
> +    uintptr_t pc = qemu_plugin_tb_vaddr(tb);

qemu_plugin_tb_vaddr() return uint64_t, so this looks wrong to me, too.

  Thomas