Skip to contentSkip to conversation

target-sh4: Use glib allocator in movcal helper

PATCH In review Peter Maydell 2 participants 4 messages Jul 12, 2016 – Jul 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-sh4: Use glib allocator in movcal helper

Coverity spots that helper_movcal() calls malloc() but doesn't check for failure. Fix this by switching to the glib allocation functions, which abort on allocation failure.

---
 target-sh4/op_helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target-sh4/op_helper.c +4 -3
index 303e83e..40dd1cf 100644
@@ -109,7 +109,8 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
 {
     if (cpu_sh4_is_cached (env, address))
     {
-	memory_content *r = malloc (sizeof(memory_content));
+        memory_content *r = g_new(memory_content, 1);
+
 	r->address = address;
 	r->value = value;
 	r->next = NULL;
@@ -126,7 +127,7 @@ void helper_discard_movcal_backup(CPUSH4State *env)
     while(current)
     {
 	memory_content *next = current->next;
-	free (current);
+        g_free(current);
 	env->movcal_backup = current = next;
 	if (current == NULL)
 	    env->movcal_backup_tail = &(env->movcal_backup);
@@ -149,7 +150,7 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)
 		env->movcal_backup_tail = current;
 	    }
 
-	    free (*current);
+            g_free(*current);
 	    *current = next;
 	    break;
 	}
Signature · 1 line
1.9.1
#1 lore raw

Ping?

thanks
-- PMM

Quoted 43 lines · Peter Maydell

Coverity spots that helper_movcal() calls malloc() but doesn't check for failure. Fix this by switching to the glib allocation functions, which abort on allocation failure.

---
 target-sh4/op_helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
target-sh4/op_helper.c +4 -4
index 303e83e..40dd1cf 100644
@@ -109,7 +109,8 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
 {
     if (cpu_sh4_is_cached (env, address))
     {
-       memory_content *r = malloc (sizeof(memory_content));
+        memory_content *r = g_new(memory_content, 1);
+
        r->address = address;
        r->value = value;
        r->next = NULL;
@@ -126,7 +127,7 @@ void helper_discard_movcal_backup(CPUSH4State *env)
     while(current)
     {
        memory_content *next = current->next;
-       free (current);
+        g_free(current);
        env->movcal_backup = current = next;
        if (current == NULL)
            env->movcal_backup_tail = &(env->movcal_backup);
@@ -149,7 +150,7 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)
                env->movcal_backup_tail = current;
            }
 
-           free (*current);
+            g_free(*current);
            *current = next;
            break;
        }
--

1.9.1

#2 lore raw
Quoted 14 lines · Peter Maydell

Ping?

thanks
-- PMM

Quoted 8 lines · Peter Maydell

Coverity spots that helper_movcal() calls malloc() but doesn't check for failure. Fix this by switching to the glib allocation functions, which abort on allocation failure.

---
 target-sh4/op_helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

I have just looked at it and test it. It's all fine, sorry for the delay.

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
author Applied
#3 lore raw
Quoted 16 lines · Aurelien Jarno
Quoted 14 lines · Peter Maydell

Ping?

thanks
-- PMM

Quoted 8 lines · Peter Maydell

Coverity spots that helper_movcal() calls malloc() but doesn't check for failure. Fix this by switching to the glib allocation functions, which abort on allocation failure.

---
 target-sh4/op_helper.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Quoted 4 lines

I have just looked at it and test it. It's all fine, sorry for the delay.

Applied to master, thanks.

-- PMM