[Spice-devel] [spice-server PATCH v1 7/12] clang-noise
Victor Toso
victortoso at redhat.com
Wed Aug 5 05:23:21 PDT 2015
This is a 'fix' for several clang warnings about alignment. It doesn't
seem real trouble IMO so ignoring cast-align flag should be okay.
Example:
red_parse_qxl.c:846:17: error: cast from 'uint8_t *'
(aka 'unsigned char *') to 'SpiceRasterGlyph *'
(aka 'struct SpiceRasterGlyph *') increases required alignment
from 1 to 4 [-Werror,-Wcast-align]
glyph = (SpiceRasterGlyph*)
^~~~~~~~~~~~~~~~~~~
---
server/lz4_encoder.c | 2 +-
server/red_parse_qxl.c | 2 +-
server/red_worker.c | 4 ++--
server/reds.c | 8 ++++----
server/reds_stream.c | 2 +-
server/snd_worker.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/server/lz4_encoder.c b/server/lz4_encoder.c
index b3e38b2..90daf16 100644
--- a/server/lz4_encoder.c
+++ b/server/lz4_encoder.c
@@ -86,7 +86,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);
+ *((uint32_t *)(void *)compressed_lines) = htonl(enc_size);
out_size += enc_size += 4;
already_copied = 0;
diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index 5b1befa..f17606d 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -839,7 +839,7 @@ static SpiceString *red_get_string(RedMemSlotInfo *slots, int group_id,
spice_assert((QXLRasterGlyph*)(&start->data[glyph_size]) <= end);
memcpy(glyph->data, start->data, glyph_size);
start = (QXLRasterGlyph*)(&start->data[glyph_size]);
- glyph = (SpiceRasterGlyph*)
+ glyph = (SpiceRasterGlyph*)(void *)
(((uint8_t *)glyph) +
SPICE_ALIGN(sizeof(SpiceRasterGlyph) + glyph_size, 4));
}
diff --git a/server/red_worker.c b/server/red_worker.c
index 4584b36..736cd51 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -3969,7 +3969,7 @@ static int rgb32_data_has_alpha(int width, int height, size_t stride,
has_alpha = FALSE;
while (height-- > 0) {
- line = (uint32_t *)data;
+ line = (uint32_t *)(void *)data;
end = line + width;
data += stride;
while (line != end) {
@@ -6002,7 +6002,7 @@ static BitmapGradualType _get_bitmap_graduality_level(RedWorker *worker, SpiceBi
x = bitmap->x;
switch (bitmap->format) {
case SPICE_BITMAP_FMT_16BIT:
- compute_lines_gradual_score_rgb16((rgb16_pixel_t *)chunk[i].data, x, num_lines,
+ compute_lines_gradual_score_rgb16((rgb16_pixel_t *)(void *)chunk[i].data, x, num_lines,
&chunk_score, &chunk_num_samples);
break;
case SPICE_BITMAP_FMT_24BIT:
diff --git a/server/reds.c b/server/reds.c
index cec28b8..8c31f7d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1334,7 +1334,7 @@ static const uint32_t *red_link_info_get_caps(const RedLinkInfo *link)
{
const uint8_t *caps_start = (const uint8_t *)link->link_mess;
- return (const uint32_t *)(caps_start + link->link_mess->caps_offset);
+ return (const uint32_t *)(void *)(caps_start + link->link_mess->caps_offset);
}
static bool red_link_info_test_capability(const RedLinkInfo *link, uint32_t cap)
@@ -1624,7 +1624,7 @@ static void reds_handle_main_link(RedLinkInfo *link)
link->stream = NULL;
link->link_mess = NULL;
reds_link_free(link);
- caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
+ caps = (uint32_t *)(void *)((uint8_t *)link_mess + link_mess->caps_offset);
client = red_client_new(mig_target);
ring_add(&reds->clients, &client->link);
reds->num_clients++;
@@ -1705,7 +1705,7 @@ static void reds_channel_do_link(RedChannel *channel, RedClient *client,
spice_assert(link_msg);
spice_assert(stream);
- caps = (uint32_t *)((uint8_t *)link_msg + link_msg->caps_offset);
+ caps = (uint32_t *)(void *)((uint8_t *)link_msg + link_msg->caps_offset);
channel->client_cbs.connect(channel, client, stream,
red_client_during_migrate_at_target(client),
link_msg->num_common_caps,
@@ -2104,7 +2104,7 @@ static void reds_handle_read_link_done(void *opaque)
link_mess->num_common_caps = GUINT32_FROM_LE(link_mess->num_common_caps);
num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
- caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
+ caps = (uint32_t *)(void *)((uint8_t *)link_mess + link_mess->caps_offset);
if (num_caps && (num_caps * sizeof(uint32_t) + link_mess->caps_offset >
link->link_header.size ||
diff --git a/server/reds_stream.c b/server/reds_stream.c
index 1a595b2..8c49576 100644
--- a/server/reds_stream.c
+++ b/server/reds_stream.c
@@ -326,7 +326,7 @@ RedsStream *reds_stream_new(int socket)
RedsStream *stream;
stream = spice_malloc0(sizeof(RedsStream) + sizeof(RedsStreamPrivate));
- stream->priv = (RedsStreamPrivate *)(((char *)stream) + sizeof(RedsStream));
+ stream->priv = (RedsStreamPrivate *)(void *)(((char *)stream) + sizeof(RedsStream));
stream->priv->info = spice_new0(SpiceChannelEventInfo, 1);
reds_stream_set_socket(stream, socket);
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 4d404e0..7bccd74 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -314,7 +314,7 @@ static int snd_record_handle_write(RecordChannel *record_channel, size_t size, v
packet = (SpiceMsgcRecordPacket *)message;
if (record_channel->mode == SPICE_AUDIO_DATA_MODE_RAW) {
- data = (uint32_t *)packet->data;
+ data = (uint32_t *)(void *)packet->data;
size = packet->data_size >> 2;
size = MIN(size, RECORD_SAMPLES_SIZE);
} else {
@@ -323,7 +323,7 @@ static int snd_record_handle_write(RecordChannel *record_channel, size_t size, v
if (snd_codec_decode(record_channel->codec, packet->data, packet->data_size,
record_channel->decode_buf, &decode_size) != SND_CODEC_OK)
return FALSE;
- data = (uint32_t *) record_channel->decode_buf;
+ data = (uint32_t *)(void *)record_channel->decode_buf;
size = decode_size >> 2;
}
--
2.4.3
More information about the Spice-devel
mailing list