Re: [Spice-devel] [spice-server] cursor: Consistently use g_memdup() for cursor data

2018-04-05 Thread Frediano Ziglio
> 
> On Thu, Apr 05, 2018 at 10:55:13AM +0200, Christophe Fergeau wrote:
> > On Thu, Apr 05, 2018 at 04:43:17AM -0400, Frediano Ziglio wrote:
> > > > 
> > > > Currently, red-parse-qxl.c open codes g_memdup() when it needs to
> > > 
> > > "open codes" ?
> > > well, currently uses g_malloc+memcpy which can be rewritten with
> > > g_memdup.
> > 
> > Yes, doing this can be seen as reimplementing g_memdup, which I'd call
> > "open code".  I'll reformulate :)
> 
> I changed the full log to
> 
> "Currently, red-parse-qxl.c uses g_malloc+memcpy to duplicate the cursor
> data when it could use g_memdup() instead. red-stream-device.c does the
> same thing but uses spice_memdup(). This commit makes use of g_memdup()
> in both cases so that this memory is consistently allocated through
> glib."
> 
> 
> > 
> > Christophe
> 

Fine for me,

Acked-by: Frediano Ziglio 

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-server] cursor: Consistently use g_memdup() for cursor data

2018-04-05 Thread Christophe Fergeau
On Thu, Apr 05, 2018 at 10:55:13AM +0200, Christophe Fergeau wrote:
> On Thu, Apr 05, 2018 at 04:43:17AM -0400, Frediano Ziglio wrote:
> > > 
> > > Currently, red-parse-qxl.c open codes g_memdup() when it needs to
> > 
> > "open codes" ?
> > well, currently uses g_malloc+memcpy which can be rewritten with
> > g_memdup.
> 
> Yes, doing this can be seen as reimplementing g_memdup, which I'd call
> "open code".  I'll reformulate :)

I changed the full log to

"Currently, red-parse-qxl.c uses g_malloc+memcpy to duplicate the cursor
data when it could use g_memdup() instead. red-stream-device.c does the
same thing but uses spice_memdup(). This commit makes use of g_memdup()
in both cases so that this memory is consistently allocated through
glib."


> 
> Christophe



> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-server] cursor: Consistently use g_memdup() for cursor data

2018-04-05 Thread Christophe Fergeau
On Thu, Apr 05, 2018 at 04:43:17AM -0400, Frediano Ziglio wrote:
> > 
> > Currently, red-parse-qxl.c open codes g_memdup() when it needs to
> 
> "open codes" ?
> well, currently uses g_malloc+memcpy which can be rewritten with
> g_memdup.

Yes, doing this can be seen as reimplementing g_memdup, which I'd call
"open code".  I'll reformulate :)

Christophe


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


Re: [Spice-devel] [spice-server] cursor: Consistently use g_memdup() for cursor data

2018-04-05 Thread Frediano Ziglio
> 
> Currently, red-parse-qxl.c open codes g_memdup() when it needs to

"open codes" ?
well, currently uses g_malloc+memcpy which can be rewritten with
g_memdup.

> duplicate the cursor data, while red-stream-device.c does this using
> spice_memdup(). This commit makes use of g_memdup() in both cases so
> that this memory is consistently allocated through glib.
> 

Yes, this is potentially a bug, good catch.

> Signed-off-by: Christophe Fergeau 
> ---
>  server/red-parse-qxl.c | 3 +--
>  server/red-stream-device.c | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
> index 69748698a..d0e7eb718 100644
> --- a/server/red-parse-qxl.c
> +++ b/server/red-parse-qxl.c
> @@ -1450,8 +1450,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int
> group_id,
>  if (free_data) {
>  red->data = data;
>  } else {
> -red->data = g_malloc(size);
> -memcpy(red->data, data, size);
> +red->data = g_memdup(data, size);
>  }
>  return true;
>  }
> diff --git a/server/red-stream-device.c b/server/red-stream-device.c
> index 7f01236ba..0dcc4d609 100644
> --- a/server/red-stream-device.c
> +++ b/server/red-stream-device.c
> @@ -344,7 +344,7 @@ stream_msg_cursor_set_to_cursor_cmd(const
> StreamMsgCursorSet *msg, size_t msg_si
>  return NULL;
>  }
>  cursor->data_size = size_required;
> -cursor->data = spice_memdup(msg->data, size_required);
> +cursor->data = g_memdup(msg->data, size_required);
>  return cmd;
>  }
>  

Frediano
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [spice-server] cursor: Consistently use g_memdup() for cursor data

2018-04-05 Thread Christophe Fergeau
Currently, red-parse-qxl.c open codes g_memdup() when it needs to
duplicate the cursor data, while red-stream-device.c does this using
spice_memdup(). This commit makes use of g_memdup() in both cases so
that this memory is consistently allocated through glib.

Signed-off-by: Christophe Fergeau 
---
 server/red-parse-qxl.c | 3 +--
 server/red-stream-device.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/server/red-parse-qxl.c b/server/red-parse-qxl.c
index 69748698a..d0e7eb718 100644
--- a/server/red-parse-qxl.c
+++ b/server/red-parse-qxl.c
@@ -1450,8 +1450,7 @@ static bool red_get_cursor(RedMemSlotInfo *slots, int 
group_id,
 if (free_data) {
 red->data = data;
 } else {
-red->data = g_malloc(size);
-memcpy(red->data, data, size);
+red->data = g_memdup(data, size);
 }
 return true;
 }
diff --git a/server/red-stream-device.c b/server/red-stream-device.c
index 7f01236ba..0dcc4d609 100644
--- a/server/red-stream-device.c
+++ b/server/red-stream-device.c
@@ -344,7 +344,7 @@ stream_msg_cursor_set_to_cursor_cmd(const 
StreamMsgCursorSet *msg, size_t msg_si
 return NULL;
 }
 cursor->data_size = size_required;
-cursor->data = spice_memdup(msg->data, size_required);
+cursor->data = g_memdup(msg->data, size_required);
 return cmd;
 }
 
-- 
2.14.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel