[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] translate-all: Use proper type
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] translate-all: Use proper type |
Date: |
Tue, 18 Oct 2016 14:34:41 -0400 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Tue, Oct 18, 2016 at 10:56:20 -0400, Pranith Kumar wrote:
> gcc does not warn about the wrong type since it is a void pointer
> which can be cast to any type.
>
> Signed-off-by: Pranith Kumar <address@hidden>
> ---
> translate-all.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/translate-all.c b/translate-all.c
> index 8ca393c..c77470a 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -412,7 +412,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index,
> int alloc)
>
> /* Level 2..N-1. */
> for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) {
> - void **p = atomic_rcu_read(lp);
> + void *p = atomic_rcu_read(lp);
>
> if (p == NULL) {
> if (!alloc) {
Let me redo your patch with more context (for patches like this using
format-patch -U<n> is useful):
$ git diff -U11 translate-all.c
diff --git a/translate-all.c b/translate-all.c
index 4200869..6928ace 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -405,23 +405,23 @@ static void page_init(void)
static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
{
PageDesc *pd;
void **lp;
int i;
/* Level 1. Always allocated. */
lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1));
/* Level 2..N-1. */
for (i = V_L1_SHIFT / V_L2_BITS - 1; i > 0; i--) {
- void **p = atomic_rcu_read(lp);
+ void *p = atomic_rcu_read(lp);
if (p == NULL) {
if (!alloc) {
return NULL;
}
p = g_new0(void *, V_L2_SIZE);
atomic_rcu_set(lp, p);
}
lp = p + ((index >> (i * V_L2_BITS)) & (V_L2_SIZE - 1));
}
I prefer void **p since that matches lp's and l1_map's type.
It's true that since we're dealing with void * the compiler won't
complain either way.
Emilio