From: Andrej Valek Date: Mon, 2 Apr 2018 18:01:19 +0000 (+0200) Subject: hantek-4032l: Fix structure packing. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e80e1858efa09c4bd3164c2130e4c26bea4cbbd6;p=libsigrok.git hantek-4032l: Fix structure packing. - use pragma to handle different behavior between gcc and minGW bit-field packing - bit-field integer variables needs to be align to 2-byte boundary Compiler does not produce an error when accessing into non-__packed pointer. However, the field might not be properly aligned for this type. More information could be found on: - https://sourceforge.net/p/mingw-w64/bugs/275/ - http://www.keil.com/support/man/docs/ARMCC/armcc_chr1359124990875.htm Signed-off-by: Andrej Valek --- diff --git a/src/hardware/hantek-4032l/protocol.c b/src/hardware/hantek-4032l/protocol.c index 7b0a5798..03017ac6 100644 --- a/src/hardware/hantek-4032l/protocol.c +++ b/src/hardware/hantek-4032l/protocol.c @@ -30,7 +30,7 @@ enum h4032l_cmd { CMD_GET = 0x6b5a }; -struct __attribute__((__packed__)) h4032l_status_packet { +struct h4032l_status_packet { uint32_t magic; uint32_t values; uint32_t status; diff --git a/src/hardware/hantek-4032l/protocol.h b/src/hardware/hantek-4032l/protocol.h index b5017ed2..7328f5cb 100644 --- a/src/hardware/hantek-4032l/protocol.h +++ b/src/hardware/hantek-4032l/protocol.h @@ -77,7 +77,8 @@ enum h4032l_status { H4032L_STATUS_TRANSFER, }; -struct __attribute__((__packed__)) h4032l_trigger { +#pragma pack(push,2) +struct h4032l_trigger { struct { uint32_t edge_signal:5; uint32_t edge_type:2; @@ -99,7 +100,7 @@ struct __attribute__((__packed__)) h4032l_trigger { uint32_t combine_data; }; -struct __attribute__((__packed__)) h4032l_cmd_pkt { +struct h4032l_cmd_pkt { uint16_t magic; /* 0x017f */ uint8_t sample_rate; struct { @@ -115,6 +116,7 @@ struct __attribute__((__packed__)) h4032l_cmd_pkt { struct h4032l_trigger trigger[2]; uint16_t cmd; }; +#pragma pack(pop) struct dev_context { enum h4032l_status status;