[Spice-devel] [PATCH spice-common v2 1/3] Create common header for demarshallers declarations

Christophe Fergeau cfergeau at redhat.com
Mon Oct 15 12:24:51 UTC 2018


On Mon, Oct 15, 2018 at 12:07:14PM +0100, Frediano Ziglio wrote:
> Code generated for demarshallers define and declare some types and
> functions.
> However these types and functions are also declared separately in
> other headers resulting in potential ABI mismatch if the different

I'd prefer that we explicitly name these "other headers" rather than
letting the reader go down on a hunt for them.
Apart from this, series looks good to me,
Acked-by: Christophe Fergeau <cfergeau at redhat.com>

Christophe

> declarations do not match.
> Using a common header shared between generated code and code using
> these functions prevent potentially multiple different declarations.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  common/Makefile.am                               |  2 +-
>  .../{client_demarshallers.h => demarshallers.h}  | 16 ++++++++++------
>  common/meson.build                               |  2 +-
>  python_modules/demarshal.py                      |  1 +
>  tests/test-marshallers.c                         |  2 +-
>  5 files changed, 14 insertions(+), 9 deletions(-)
>  rename common/{client_demarshallers.h => demarshallers.h} (62%)
> 
> Changes since v1:
> - use a single header instead of 2;
> - add patches for spice-server and spice-gtk.
> 
> diff --git a/common/Makefile.am b/common/Makefile.am
> index d8e30d1..da0d941 100644
> --- a/common/Makefile.am
> +++ b/common/Makefile.am
> @@ -21,6 +21,7 @@ libspice_common_la_SOURCES =		\
>  	backtrace.h			\
>  	canvas_utils.c			\
>  	canvas_utils.h			\
> +	demarshallers.h			\
>  	draw.h				\
>  	lines.c				\
>  	lines.h				\
> @@ -63,7 +64,6 @@ EXTRA_libspice_common_la_SOURCES = 	\
>  	$(NULL)
>  
>  libspice_common_client_la_SOURCES =		\
> -	client_demarshallers.h			\
>  	client_marshallers.h			\
>  	ssl_verify.c				\
>  	ssl_verify.h				\
> diff --git a/common/client_demarshallers.h b/common/demarshallers.h
> similarity index 62%
> rename from common/client_demarshallers.h
> rename to common/demarshallers.h
> index 43c7e7d..0accb62 100644
> --- a/common/client_demarshallers.h
> +++ b/common/demarshallers.h
> @@ -14,8 +14,8 @@
>     You should have received a copy of the GNU Lesser General Public
>     License along with this library; if not, see <http://www.gnu.org/licenses/>.
>  */
> -#ifndef _H_DEMARSHAL
> -#define _H_DEMARSHAL
> +#ifndef COMMON_DEMARSHALLERS_H_
> +#define COMMON_DEMARSHALLERS_H_
>  
>  #include <stddef.h>
>  #include <spice/macros.h>
> @@ -23,12 +23,16 @@
>  SPICE_BEGIN_DECLS
>  
>  typedef void (*message_destructor_t)(uint8_t *message);
> -typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end, uint16_t message_type, int minor,
> -						size_t *size_out, message_destructor_t *free_message);
> +typedef uint8_t * (*spice_parse_channel_func_t)(uint8_t *message_start, uint8_t *message_end,
> +                                                uint16_t message_type, int minor,
> +                                                size_t *size_out,
> +                                                message_destructor_t *free_message);
>  
> -spice_parse_channel_func_t spice_get_server_channel_parser(uint32_t channel, unsigned int *max_message_type);
> +spice_parse_channel_func_t
> +spice_get_server_channel_parser(uint32_t channel, unsigned int *max_message_type);
> +spice_parse_channel_func_t
> +spice_get_client_channel_parser(uint32_t channel, unsigned int *max_message_type);
>  
>  SPICE_END_DECLS
>  
>  #endif
> -
> diff --git a/common/meson.build b/common/meson.build
> index 36ba43b..6ac55dc 100644
> --- a/common/meson.build
> +++ b/common/meson.build
> @@ -6,6 +6,7 @@ spice_common_sources = [
>    'backtrace.h',
>    'canvas_utils.c',
>    'canvas_utils.h',
> +  'demarshallers.h',
>    'draw.h',
>    'lines.c',
>    'lines.h',
> @@ -57,7 +58,6 @@ if spice_common_generate_client_code
>    ]
>  
>    spice_common_client_sources = [
> -    'client_demarshallers.h',
>      'client_marshallers.h',
>      'ssl_verify.c',
>      'ssl_verify.h',
> diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
> index 6fe3c66..36213b1 100644
> --- a/python_modules/demarshal.py
> +++ b/python_modules/demarshal.py
> @@ -1229,6 +1229,7 @@ def write_includes(writer):
>      writer.writeln("#include <spice/protocol.h>")
>      writer.writeln("#include <spice/macros.h>")
>      writer.writeln('#include <common/mem.h>')
> +    writer.writeln('#include <common/demarshallers.h>')
>      writer.newline()
>      writer.writeln("#ifdef _MSC_VER")
>      writer.writeln("#pragma warning(disable:4101)")
> diff --git a/tests/test-marshallers.c b/tests/test-marshallers.c
> index 02fbcd1..a70ac95 100644
> --- a/tests/test-marshallers.c
> +++ b/tests/test-marshallers.c
> @@ -22,7 +22,7 @@
>  #include <string.h>
>  
>  #include <common/marshaller.h>
> -#include <common/client_demarshallers.h>
> +#include <common/demarshallers.h>
>  #include "generated_test_enums.h"
>  #include "generated_test_marshallers.h"
>  
> -- 
> 2.17.2
> 
> _______________________________________________
> 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/20181015/788c8b0a/attachment.sig>


More information about the Spice-devel mailing list