Skip to contentSkip to conversation

linux-user: Remove redundant null check and replace free by g_free

PATCH Applied Stefan Weil 3 participants 4 messages Sep 4, 2012 – Sep 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: Remove redundant null check and replace free by g_free

Report from smatch:

linux-user/syscall.c:3632 do_ioctl_dm(220) info:
redundant null check on big_buf calling free()

'big_buf' was allocated by g_malloc0, therefore free was also replaced by g_free.

---
 linux-user/syscall.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
linux-user/syscall.c +1 -3
index 1513f08..c3533da 100644
@@ -3628,9 +3628,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
         unlock_user(argptr, arg, target_size);
     }
 out:
-    if (big_buf) {
-        free(big_buf);
-    }
+    g_free(big_buf);
     return ret;
 }
 
Signature · 1 line
1.7.10
#2 lore raw
In reply to Stefan Weil

Am 04.09.2012 22:14, schrieb Stefan Weil:

Quoted 18 lines

Report from smatch:

linux-user/syscall.c:3632 do_ioctl_dm(220) info:
redundant null check on big_buf calling free()

'big_buf' was allocated by g_malloc0, therefore free was also replaced by g_free.

---
  linux-user/syscall.c |    4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
linux-user/syscall.c +0 -0
index 1513f08..c3533da 100644

linux-user/syscall.c static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, · line 3634

Quoted 10 lines
linux-user/syscall.c +1 -3
@@ -3628,9 +3628,7 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd,
          unlock_user(argptr, arg, target_size);
      }
  out:
-    if (big_buf) {
-        free(big_buf);
-    }
+    g_free(big_buf);
      return ret;
  }
 

Ping? Maybe qemu-trivial can take that patch, it's trivial enough. Peter reviewed it, see http://patchwork.ozlabs.org/patch/181669/.

Regards

Stefan

#3 lore raw
In reply to Stefan Weil
Quoted 5 lines · Stefan Weil

Report from smatch:

linux-user/syscall.c:3632 do_ioctl_dm(220) info:
redundant null check on big_buf calling free()

Quoted 7 lines

'big_buf' was allocated by g_malloc0, therefore free was also replaced by g_free.

---
 linux-user/syscall.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches

Stefan