diff mbox

[v2,28/29] test-iov: replace g_malloc()+memcpy() with g_memdup()

Message ID 20170713163219.9024-29-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 13, 2017, 4:32 p.m. UTC
I found these pattern via grepping the source tree. I don't have a
coccinelle script for it!

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-iov.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé July 14, 2017, 4:27 a.m. UTC | #1
On 07/13/2017 01:32 PM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>   tests/test-iov.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tests/test-iov.c b/tests/test-iov.c
> index a22d71fd2c..fa3d75aee1 100644
> --- a/tests/test-iov.c
> +++ b/tests/test-iov.c
> @@ -167,8 +167,7 @@ static void test_io(void)
>       }
>       iov_from_buf(iov, niov, 0, buf, sz);
>   
> -    siov = g_malloc(sizeof(*iov) * niov);
> -    memcpy(siov, iov, sizeof(*iov) * niov);
> +    siov = g_memdup(iov, sizeof(*iov) * niov);
>   
>       if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
>          perror("socketpair");
>
Richard Henderson July 14, 2017, 8:44 a.m. UTC | #2
On 07/13/2017 06:32 AM, Marc-André Lureau wrote:
> I found these pattern via grepping the source tree. I don't have a
> coccinelle script for it!
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   tests/test-iov.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
diff mbox

Patch

diff --git a/tests/test-iov.c b/tests/test-iov.c
index a22d71fd2c..fa3d75aee1 100644
--- a/tests/test-iov.c
+++ b/tests/test-iov.c
@@ -167,8 +167,7 @@  static void test_io(void)
     }
     iov_from_buf(iov, niov, 0, buf, sz);
 
-    siov = g_malloc(sizeof(*iov) * niov);
-    memcpy(siov, iov, sizeof(*iov) * niov);
+    siov = g_memdup(iov, sizeof(*iov) * niov);
 
     if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
        perror("socketpair");