[spice-server PATCH v2 09/10] smartcard: use SPICE_ALIGNED_CAST

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

 



In order to avoid false posive alignment warnings
clang:
smartcard.c:131:29: error: cast from 'uint8_t *' (aka 'unsigned char *')
to 'VSCMsgHeader *' (aka 'struct VSCMsgHeader *') increases required
alignment from 1 to 4 [-Werror,-Wcast-align]

VSCMsgHeader *vheader = (VSCMsgHeader*)state->buf;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~
---
 server/smartcard.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/server/smartcard.c b/server/smartcard.c
index aad22aa..3816cd5 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -128,7 +128,7 @@ SpiceCharDeviceMsgToClient *smartcard_read_msg_from_device(SpiceCharDeviceInstan
 {
     SmartCardDeviceState *state = opaque;
     SpiceCharDeviceInterface *sif = SPICE_CONTAINEROF(sin->base.sif, SpiceCharDeviceInterface, base);
-    VSCMsgHeader *vheader = (VSCMsgHeader*)state->buf;
+    VSCMsgHeader *vheader = SPICE_ALIGNED_CAST(VSCMsgHeader, state->buf);
     int n;
     int remaining;
     int actual_length;
@@ -328,7 +328,7 @@ static void smartcard_char_device_notify_reader_add(SmartCardDeviceState *st)
         return;
     }
     st->reader_added = TRUE;
-    vheader = (VSCMsgHeader *)write_buf->buf;
+    vheader = SPICE_ALIGNED_CAST(VSCMsgHeader, write_buf->buf);
     vheader->type = VSC_ReaderAdd;
     vheader->reader_id = st->reader_id;
     vheader->length = 0;
@@ -375,7 +375,7 @@ static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState *st)
         return;
     }
     st->reader_added = FALSE;
-    vheader = (VSCMsgHeader *)write_buf->buf;
+    vheader = SPICE_ALIGNED_CAST(VSCMsgHeader, write_buf->buf);
     vheader->type = VSC_ReaderRemove;
     vheader->reader_id = st->reader_id;
     vheader->length = 0;
@@ -652,7 +652,7 @@ static void smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer *write_
     VSCMsgHeader *vheader;
     uint32_t actual_length;
 
-    vheader = (VSCMsgHeader *)write_buf->buf;
+    vheader = SPICE_ALIGNED_CAST(VSCMsgHeader, write_buf->buf);
     actual_length = vheader->length;
 
     spice_assert(vheader->reader_id <= g_smartcard_readers.num);
@@ -688,7 +688,7 @@ static void smartcard_device_state_restore_partial_read(SmartCardDeviceState *st
     if (mig_data->read_size < sizeof(VSCMsgHeader)) {
         spice_assert(state->buf_size >= mig_data->read_size);
     } else {
-        smartcard_read_buf_prepare(state, (VSCMsgHeader *)read_data);
+        smartcard_read_buf_prepare(state, SPICE_ALIGNED_CAST(VSCMsgHeader, read_data));
     }
     memcpy(state->buf, read_data, mig_data->read_size);
     state->buf_used = mig_data->read_size;
@@ -742,7 +742,7 @@ static int smartcard_channel_handle_message(RedChannelClient *rcc,
                                             uint32_t size,
                                             uint8_t *msg)
 {
-    VSCMsgHeader* vheader = (VSCMsgHeader*)msg;
+    VSCMsgHeader* vheader = SPICE_ALIGNED_CAST(VSCMsgHeader, msg);
     SmartCardChannelClient *scc = SPICE_CONTAINEROF(rcc, SmartCardChannelClient, base);
 
     if (type != SPICE_MSGC_SMARTCARD_DATA) {
-- 
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]