[spice-server PATCH v1 3/12] jpeg_encoder: fix alignment warnings (convert_line)

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

 



As the input line could be uint8_t*, uint16_t* or uint32_t*, changing
the default from uint8_t* to void* seems the correct choice to deal with
upcasting warnings.

clang output:
jpeg_encoder.c:109:26: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'uint16_t *' (aka 'unsigned short *')
increases required alignment from 1 to 2 [-Werror,-Wcast-align]
  uint16_t *src_line = (uint16_t *)line;
                       ^~~~~~~~~~~~~~~~

jpeg_encoder.c:144:26: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'uint32_t *' (aka 'unsigned int *')
increases required alignment from 1 to 4 [-Werror,-Wcast-align]
  uint32_t *src_line = (uint32_t *)line;
                       ^~~~~~~~~~~~~~~~
---
 server/jpeg_encoder.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/server/jpeg_encoder.c b/server/jpeg_encoder.c
index 01732ff..0296e9b 100644
--- a/server/jpeg_encoder.c
+++ b/server/jpeg_encoder.c
@@ -35,7 +35,7 @@ typedef struct JpegEncoder {
         int height;
         int stride;
         unsigned int out_size;
-        void (*convert_line_to_RGB24) (uint8_t *line, int width, uint8_t **out_line);
+        void (*convert_line_to_RGB24) (void *line, int width, uint8_t **out_line);
     } cur_image;
 } JpegEncoder;
 
@@ -104,9 +104,9 @@ void jpeg_encoder_destroy(JpegEncoderContext* encoder)
     free(encoder);
 }
 
-static void convert_RGB16_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
+static void convert_RGB16_to_RGB24(void *line, int width, uint8_t **out_line)
 {
-    uint16_t *src_line = (uint16_t *)line;
+    uint16_t *src_line = line;
     uint8_t *out_pix;
     int x;
 
@@ -122,11 +122,11 @@ static void convert_RGB16_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
    }
 }
 
-static void convert_BGR24_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
+static void convert_BGR24_to_RGB24(void *in_line, int width, uint8_t **out_line)
 {
     int x;
     uint8_t *out_pix;
-
+    uint8_t *line = in_line;
     spice_assert(out_line && *out_line);
 
     out_pix = *out_line;
@@ -139,9 +139,9 @@ static void convert_BGR24_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
     }
 }
 
-static void convert_BGRX32_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
+static void convert_BGRX32_to_RGB24(void *line, int width, uint8_t **out_line)
 {
-    uint32_t *src_line = (uint32_t *)line;
+    uint32_t *src_line = line;
     uint8_t *out_pix;
     int x;
 
@@ -157,7 +157,7 @@ static void convert_BGRX32_to_RGB24(uint8_t *line, int width, uint8_t **out_line
     }
 }
 
-static void convert_RGB24_to_RGB24(uint8_t *line, int width, uint8_t **out_line)
+static void convert_RGB24_to_RGB24(void *line, int width, uint8_t **out_line)
 {
     *out_line = line;
 }
-- 
2.4.3

_______________________________________________
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]