[Spice-devel] [PATCH spice-common 3/7] codegen: Use a better type for pointer converted to integer

2019-02-18 Thread Frediano Ziglio
Although on the platform we support size_t and uintptr_t are
the same on some platform the size_t can (in theory) be smaller
than the necessary integer to store a pointer.

Signed-off-by: Frediano Ziglio 
---
 python_modules/demarshal.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index 36213b1..68532a9 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -847,7 +847,7 @@ def write_array_parser(writer, member, nelements, array, 
dest, scope):
 write_container_parser(writer, element_type, dest2)
 if array.has_attr("ptr_array"):
 writer.comment("Align ptr_array element to 4 
bytes").newline()
-writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 
4)")
+writer.assign("end", "(uint8_t 
*)SPICE_ALIGN((uintptr_t)end, 4)")
 
 def write_parse_pointer_core(writer, target_type, offset, at_end, dest, 
member_name, scope):
 writer.assign("ptr_info[n_ptr].offset", offset)
@@ -968,7 +968,7 @@ def write_ptr_info_check(writer):
 writer.assign("*%s" % dest, "NULL")
 with writer.block(" else"):
 writer.comment("Align to 32 bit").newline()
-writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)")
+writer.assign("end", "(uint8_t *)SPICE_ALIGN((uintptr_t)end, 
4)")
 writer.assign("*%s" % dest, "(void *)end")
 writer.assign("end", "%s(message_start, message_end, end, 
&ptr_info[%s])" % (function, index))
 writer.error_check("end == NULL")
-- 
2.20.1

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

Re: [Spice-devel] [PATCH spice-common 3/7] codegen: Use a better type for pointer converted to integer

2019-02-20 Thread Christophe Fergeau
On Mon, Feb 18, 2019 at 04:01:25PM +, Frediano Ziglio wrote:
> Although on the platform we support size_t and uintptr_t are
> the same on some platform the size_t can (in theory) be smaller

"the same, on some platforms size_t can ..." (took me a while to parse
the sentence without the comma)

Acked-by: Christophe Fergeau 

> than the necessary integer to store a pointer.
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  python_modules/demarshal.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
> index 36213b1..68532a9 100644
> --- a/python_modules/demarshal.py
> +++ b/python_modules/demarshal.py
> @@ -847,7 +847,7 @@ def write_array_parser(writer, member, nelements, array, 
> dest, scope):
>  write_container_parser(writer, element_type, dest2)
>  if array.has_attr("ptr_array"):
>  writer.comment("Align ptr_array element to 4 
> bytes").newline()
> -writer.assign("end", "(uint8_t 
> *)SPICE_ALIGN((size_t)end, 4)")
> +writer.assign("end", "(uint8_t 
> *)SPICE_ALIGN((uintptr_t)end, 4)")
>  
>  def write_parse_pointer_core(writer, target_type, offset, at_end, dest, 
> member_name, scope):
>  writer.assign("ptr_info[n_ptr].offset", offset)
> @@ -968,7 +968,7 @@ def write_ptr_info_check(writer):
>  writer.assign("*%s" % dest, "NULL")
>  with writer.block(" else"):
>  writer.comment("Align to 32 bit").newline()
> -writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 
> 4)")
> +writer.assign("end", "(uint8_t *)SPICE_ALIGN((uintptr_t)end, 
> 4)")
>  writer.assign("*%s" % dest, "(void *)end")
>  writer.assign("end", "%s(message_start, message_end, end, 
> &ptr_info[%s])" % (function, index))
>  writer.error_check("end == NULL")
> -- 
> 2.20.1
> 
> ___
> 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