Changed malloc to g_malloc, free to g_free in linux-user/qemu.h
PATCH 1/1 Changed malloc to g_malloc, free to g_free in linux-user/qemu.h
--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/qemu.h +2 -2
@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else
@@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr); +g_free (host_ptr);#endif }
Signature · 1 line
1.9.1
Hi,
Can I get a respond for this patch. Is it complete, or did I miss something?
Quoted 30 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +2
-3@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr); +g_free (host_ptr);#endif } --1.9.1
Signature · 6 lines
With regards, Md Haris Iqbal, Placement Coordinator, MTech IT NITK Surathkal, Contact: +91 8861996962
Hi,
Patch is attached in the previous mail. Looking forward to your review.
Quoted 47 lines · haris iqbal
Hi,
Can I get a respond for this patch. Is it complete, or did I miss something?
Quoted 28 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +2
-3@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr); +g_free (host_ptr);#endif } --Quoted 2 lines
1.9.1
--
With regards,
Md Haris Iqbal,
Placement Coordinator, MTech IT
NITK Surathkal,
Contact: +91 8861996962
Signature · 6 lines
With regards, Md Haris Iqbal, Placement Coordinator, MTech IT NITK Surathkal, Contact: +91 8861996962
Quoted 19 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-1@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 7 lines
linux-user/qemu.h +1
-1@@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr); +g_free (host_ptr);#endif }
If I understand correctly either lock_user() or lock_user_string() may be followed by unlock_user(). If you change unlock_user() to g_free() then you also need to change lock_user_string() to g_malloc() to avoid a malloc()/g_free() mismatch.
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-2@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr);
Quoted 8 lines
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 3 lines
linux-user/qemu.h +1
-0+g_free (host_ptr);#endif }If I understand correctly either
lock_user()orlock_user_string()may be followed byunlock_user(). If you changeunlock_user()tog_free()then you also need to changelock_user_string()tog_malloc()to avoid a malloc()/g_free() mismatch.
lock_user_string() does not use malloc itself, but calls lock_user() from itself.
Signature · 6 lines
With regards, Md Haris Iqbal, Placement Coordinator, MTech IT NITK Surathkal, Contact: +91 8861996962
Quoted 34 lines · haris iqbal
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-2@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr);Quoted 8 lines
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 3 lines
linux-user/qemu.h +1
-0+g_free (host_ptr);#endif }If I understand correctly either
lock_user()orlock_user_string()may be followed byunlock_user(). If you changeunlock_user()tog_free()then you also need to changelock_user_string()tog_malloc()to avoid a malloc()/g_free() mismatch.
Quoted 2 lines
lock_user_string()does not use malloc itself, but callslock_user()from itself.
You are right. The reason I got confused is because there are 3 versions of lock_user(): linux-user, bsd-user, and include/exec/softmmu-semi.h.
Please send equivalent patches for the other 2 versions as well. This way they stay consistent.
Thanks,
Stefan
Quoted 38 lines · Stefan Hajnoczi
Quoted 34 lines · haris iqbal
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-2@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr);Quoted 8 lines
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 3 lines
linux-user/qemu.h +1
-0+g_free (host_ptr);#endif }If I understand correctly either
lock_user()orlock_user_string()may be followed byunlock_user(). If you changeunlock_user()tog_free()then you also need to changelock_user_string()tog_malloc()to avoid a malloc()/g_free() mismatch.Quoted 2 lines
lock_user_string()does not use malloc itself, but callslock_user()from itself.
Quoted 6 lines
You are right. The reason I got confused is because there are 3 versions of
lock_user(): linux-user, bsd-user, andinclude/exec/softmmu-semi.h.Please send equivalent patches for the other 2 versions as well. This way they stay consistent.
Will do. Actually as they different files, I was told to send patches separately.
And I wanted to wait till this one is reviewed, so I don't repeat any mistake if there are in this one.
Quoted 3 lines
Thanks,
Stefan
Signature · 6 lines
With regards, Md Haris Iqbal, Placement Coordinator, MTech IT NITK Surathkal, Contact: +91 8861996962
Just a reminder. any more changes needed for this patch? or can it be merged?
Quoted 66 lines · haris iqbal
Quoted 38 lines · Stefan Hajnoczi
Quoted 34 lines · haris iqbal
Quoted 24 lines · Stefan Hajnoczi
Quoted 23 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-2@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr);Quoted 8 lines
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 3 lines
linux-user/qemu.h +1
-0+g_free (host_ptr);#endif }If I understand correctly either
lock_user()orlock_user_string()may be followed byunlock_user(). If you changeunlock_user()tog_free()then you also need to changelock_user_string()tog_malloc()to avoid a malloc()/g_free() mismatch.Quoted 2 lines
lock_user_string()does not use malloc itself, but callslock_user()from itself.Quoted 6 lines
You are right. The reason I got confused is because there are 3 versions of
lock_user(): linux-user, bsd-user, andinclude/exec/softmmu-semi.h.Please send equivalent patches for the other 2 versions as well. This way they stay consistent.
Will do. Actually as they different files, I was told to send patches separately.
And I wanted to wait till this one is reviewed, so I don't repeat any mistake if there are in this one.
Quoted 3 lines
Thanks,
Stefan--
With regards,
Md Haris Iqbal,
Placement Coordinator, MTech IT
NITK Surathkal,
Contact: +91 8861996962
Signature · 6 lines
With regards, Md Haris Iqbal, Placement Coordinator, MTech IT NITK Surathkal, Contact: +91 8861996962
Quoted 4 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 19 lines · Md Haris Iqbal
Signed-off-by Md Haris Iqbal <[email protected]>--- linux-user/qemu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/qemu.h +1
-1@@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy#ifdef DEBUG_REMAP {void *addr; - addr =malloc (len); + addr =g_malloc (len);if (copy)memcpy (addr,g2h (guest_addr), len);else
linux-user/qemu.h static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, · line 412
Quoted 7 lines
linux-user/qemu.h +1
-1@@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,return ;if (len >0 )memcpy (g2h (guest_addr), host_ptr, len); -free (host_ptr); +g_free (host_ptr);#endif }
This is a very old patch, somehow missed by me at that time. Applied to -trivial now, thank you!
/mjt