GUACAMOLE-249: Test endianness of platform without violating strict aliasing rules.
Dereferencing a uint8_t array as uint32_t causes a build failure with some compilers as it breaks strict aliasing rules.
This commit is contained in:
parent
4b1243fbf8
commit
e9846945c7
@ -25,14 +25,18 @@
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
UINT32 guac_rdp_get_native_pixel_format(BOOL alpha) {
|
||||
|
||||
uint8_t color[] = { 0x0A, 0x0B, 0x0C, 0x0D };
|
||||
uint32_t int_value;
|
||||
uint8_t raw_bytes[4] = { 0x0A, 0x0B, 0x0C, 0x0D };
|
||||
|
||||
memcpy(&int_value, raw_bytes, sizeof(raw_bytes));
|
||||
|
||||
/* Local platform stores bytes in decreasing order of significance
|
||||
* (big-endian) */
|
||||
if (*((uint32_t*) color) == 0x0A0B0C0D)
|
||||
if (int_value == 0x0A0B0C0D)
|
||||
return alpha ? PIXEL_FORMAT_ARGB32 : PIXEL_FORMAT_XRGB32;
|
||||
|
||||
/* Local platform stores bytes in increasing order of significance
|
||||
|
Loading…
Reference in New Issue
Block a user