[Spice-devel] [PATCH spice-common] reuse {start, end}-packed headers to specify packed structure

Victor Toso victortoso at redhat.com
Thu Jun 15 10:16:44 UTC 2017


Hi,

I would change the short log from

"reuse {start, end}-packed headers to specify packed structure"

to "Use SPICE_ATTR_PACKED instead of custom ATTR_PACKED"

And mention the start-packed/end-packed headers in the commit log.

On Mon, Jun 12, 2017 at 10:39:17AM +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>

Commit log comment is just a suggestion, feel free to take it or not
Acked-by: Victor Toso <victortoso at redhat.com>

> ---
>  common/lz.c   | 21 +++++----------------
>  common/quic.c | 24 +++++++-----------------
>  2 files changed, 12 insertions(+), 33 deletions(-)
> 
> diff --git a/common/lz.c b/common/lz.c
> index 2589223..28f450b 100644
> --- a/common/lz.c
> +++ b/common/lz.c
> @@ -382,30 +382,23 @@ void lz_destroy(LzContext *lz)
>  #endif
>  
>  
> -#ifdef __GNUC__
> -#define ATTR_PACKED __attribute__ ((__packed__))
> -#else
> -#define ATTR_PACKED
> -#pragma pack(push)
> -#pragma pack(1)
> -#endif
> -
> +#include <spice/start-packed.h>
>  
>  /* the palette images will be treated as one byte pixels. Their width should be transformed
>     accordingly.
>  */
> -typedef struct ATTR_PACKED one_byte_pixel_t {
> +typedef struct SPICE_ATTR_PACKED one_byte_pixel_t {
>      uint8_t a;
>  } one_byte_pixel_t;
>  
> -typedef struct ATTR_PACKED rgb32_pixel_t {
> +typedef struct SPICE_ATTR_PACKED rgb32_pixel_t {
>      uint8_t b;
>      uint8_t g;
>      uint8_t r;
>      uint8_t pad;
>  } rgb32_pixel_t;
>  
> -typedef struct ATTR_PACKED rgb24_pixel_t {
> +typedef struct SPICE_ATTR_PACKED rgb24_pixel_t {
>      uint8_t b;
>      uint8_t g;
>      uint8_t r;
> @@ -413,11 +406,7 @@ typedef struct ATTR_PACKED rgb24_pixel_t {
>  
>  typedef uint16_t rgb16_pixel_t;
>  
> -#ifndef __GNUC__
> -#pragma pack(pop)
> -#endif
> -
> -#undef ATTR_PACKED
> +#include <spice/end-packed.h>
>  
>  
>  #define MAX_COPY 32
> diff --git a/common/quic.c b/common/quic.c
> index 2cd1f0d..d22a9b7 100644
> --- a/common/quic.c
> +++ b/common/quic.c
> @@ -741,39 +741,33 @@ static inline void init_decode_io(Encoder *encoder)
>      encoder->io_available_bits = 0;
>  }
>  
> -#ifdef __GNUC__
> -#define ATTR_PACKED __attribute__ ((__packed__))
> -#else
> -#define ATTR_PACKED
> -#pragma pack(push)
> -#pragma pack(1)
> -#endif
> +#include <spice/start-packed.h>
>  
> -typedef struct ATTR_PACKED one_byte_pixel_t {
> +typedef struct SPICE_ATTR_PACKED one_byte_pixel_t {
>      BYTE a;
>  } one_byte_t;
>  
> -typedef struct ATTR_PACKED three_bytes_pixel_t {
> +typedef struct SPICE_ATTR_PACKED three_bytes_pixel_t {
>      BYTE a;
>      BYTE b;
>      BYTE c;
>  } three_bytes_t;
>  
> -typedef struct ATTR_PACKED four_bytes_pixel_t {
> +typedef struct SPICE_ATTR_PACKED four_bytes_pixel_t {
>      BYTE a;
>      BYTE b;
>      BYTE c;
>      BYTE d;
>  } four_bytes_t;
>  
> -typedef struct ATTR_PACKED rgb32_pixel_t {
> +typedef struct SPICE_ATTR_PACKED rgb32_pixel_t {
>      BYTE b;
>      BYTE g;
>      BYTE r;
>      BYTE pad;
>  } rgb32_pixel_t;
>  
> -typedef struct ATTR_PACKED rgb24_pixel_t {
> +typedef struct SPICE_ATTR_PACKED rgb24_pixel_t {
>      BYTE b;
>      BYTE g;
>      BYTE r;
> @@ -781,11 +775,7 @@ typedef struct ATTR_PACKED rgb24_pixel_t {
>  
>  typedef uint16_t rgb16_pixel_t;
>  
> -#ifndef __GNUC__
> -#pragma pack(pop)
> -#endif
> -
> -#undef ATTR_PACKED
> +#include <spice/end-packed.h>
>  
>  #define ONE_BYTE
>  #include "quic_tmpl.c"
> -- 
> 2.9.4
> 
> _______________________________________________
> 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/20170615/8a6e15ea/attachment.sig>


More information about the Spice-devel mailing list