Re: [PATCH 4/5] LZ4: Implement htonl to remove dependency on arpa/inte.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Same comment as before, you can just use GUINT32_TO_BE

Christophe

On Thu, Jan 22, 2015 at 05:21:07PM +0100, Javier Celaya wrote:
> ---
>  server/lz4_encoder.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/server/lz4_encoder.c b/server/lz4_encoder.c
> index 2327e9a..4f0f3c8 100644
> --- a/server/lz4_encoder.c
> +++ b/server/lz4_encoder.c
> @@ -22,7 +22,6 @@
>  
>  #define SPICE_LOG_DOMAIN "SpiceLz4Encoder"
>  
> -#include <arpa/inet.h>
>  #include <lz4.h>
>  #include "red_common.h"
>  #include "lz4_encoder.h"
> @@ -31,6 +30,16 @@ typedef struct Lz4Encoder {
>      Lz4EncoderUsrContext *usr;
>  } Lz4Encoder;
>  
> +static inline void encode32(uint8_t *buffer, uint32_t value)
> +{
> +    // Network order -> big endian
> +    int i;
> +    for (i = 3; i > -1; --i) {
> +        buffer[i] = value & 0xFF;
> +        value >>= 8;
> +    }
> +}
> +
>  Lz4EncoderContext* lz4_encoder_create(Lz4EncoderUsrContext *usr)
>  {
>      Lz4Encoder *enc;
> @@ -85,7 +94,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
>              LZ4_freeStream(stream);
>              return 0;
>          }
> -        *((uint32_t *)compressed_lines) = htonl(enc_size);
> +        encode32(compressed_lines, enc_size);
>  
>          out_size += enc_size += 4;
>          already_copied = 0;
> -- 
> 1.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: pgpm79DPzGgaa.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]