diff mbox

[2/2] cputlb: Tidy memset of arrays

Message ID 1386366292-5340-2-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Dec. 6, 2013, 9:44 p.m. UTC
Don't duplicate the array length computation in the memset
when plain sizeof can produce the correct results.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 cputlb.c        | 2 +-
 translate-all.c | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Aurelien Jarno Dec. 22, 2013, 6:04 p.m. UTC | #1
On Sat, Dec 07, 2013 at 10:44:52AM +1300, Richard Henderson wrote:
> Don't duplicate the array length computation in the memset
> when plain sizeof can produce the correct results.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  cputlb.c        | 2 +-
>  translate-all.c | 5 ++---
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/cputlb.c b/cputlb.c
> index d2da404..9270055 100644
> --- a/cputlb.c
> +++ b/cputlb.c
> @@ -57,7 +57,7 @@ void tlb_flush(CPUArchState *env, int flush_global)
>      cpu->current_tb = NULL;
>  
>      memset(env->tlb_table, -1, sizeof(env->tlb_table));
> -    memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
> +    memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
>  
>      env->tlb_flush_addr = -1;
>      env->tlb_flush_mask = 0;
> diff --git a/translate-all.c b/translate-all.c
> index aeda54d..66755b1 100644
> --- a/translate-all.c
> +++ b/translate-all.c
> @@ -699,11 +699,10 @@ void tb_flush(CPUArchState *env1)
>      CPU_FOREACH(cpu) {
>          CPUArchState *env = cpu->env_ptr;
>  
> -        memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
> +        memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
>      }
>  
> -    memset(tcg_ctx.tb_ctx.tb_phys_hash, 0,
> -            CODE_GEN_PHYS_HASH_SIZE * sizeof(void *));
> +    memset(tcg_ctx.tb_ctx.tb_phys_hash, 0, sizeof(tcg_ctx.tb_ctx.tb_phys_hash));
>      page_flush_tb();
>  
>      tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
diff mbox

Patch

diff --git a/cputlb.c b/cputlb.c
index d2da404..9270055 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -57,7 +57,7 @@  void tlb_flush(CPUArchState *env, int flush_global)
     cpu->current_tb = NULL;
 
     memset(env->tlb_table, -1, sizeof(env->tlb_table));
-    memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof (void *));
+    memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
 
     env->tlb_flush_addr = -1;
     env->tlb_flush_mask = 0;
diff --git a/translate-all.c b/translate-all.c
index aeda54d..66755b1 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -699,11 +699,10 @@  void tb_flush(CPUArchState *env1)
     CPU_FOREACH(cpu) {
         CPUArchState *env = cpu->env_ptr;
 
-        memset(env->tb_jmp_cache, 0, TB_JMP_CACHE_SIZE * sizeof(void *));
+        memset(env->tb_jmp_cache, 0, sizeof(env->tb_jmp_cache));
     }
 
-    memset(tcg_ctx.tb_ctx.tb_phys_hash, 0,
-            CODE_GEN_PHYS_HASH_SIZE * sizeof(void *));
+    memset(tcg_ctx.tb_ctx.tb_phys_hash, 0, sizeof(tcg_ctx.tb_ctx.tb_phys_hash));
     page_flush_tb();
 
     tcg_ctx.code_gen_ptr = tcg_ctx.code_gen_buffer;