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

Christophe Fergeau cfergeau at redhat.com
Wed Feb 20 16:45:55 UTC 2019


On Mon, Feb 18, 2019 at 04:01:25PM +0000, 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 <cfergeau at redhat.com>

> than the necessary integer to store a pointer.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20190220/ff03415f/attachment.sig>


More information about the Spice-devel mailing list