|
|
ae49b1 |
From a6e141517b86a866feba4d472ead02a9df569a9e Mon Sep 17 00:00:00 2001
|
|
|
ae49b1 |
From: Raphael Kubo da Costa <rakuco@FreeBSD.org>
|
|
|
ae49b1 |
Date: Tue, 11 Sep 2012 22:50:18 +0300
|
|
|
ae49b1 |
Subject: [PATCH 1/3] Work around a gcc bug with anonymous structs and unions.
|
|
|
ae49b1 |
|
|
|
ae49b1 |
GCC < 4.6 failed to parse the declaration of ws_header_t correctly because
|
|
|
ae49b1 |
it did not accept anonymous structs and unions. [1]
|
|
|
ae49b1 |
|
|
|
ae49b1 |
Work around the bug by adding names to the unions and structs. Ugly, but
|
|
|
ae49b1 |
works.
|
|
|
ae49b1 |
|
|
|
ae49b1 |
[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784
|
|
|
ae49b1 |
---
|
|
|
ae49b1 |
libvncserver/websockets.c | 15 ++++++++++-----
|
|
|
ae49b1 |
1 file changed, 10 insertions(+), 5 deletions(-)
|
|
|
ae49b1 |
|
|
|
ae49b1 |
diff --git a/libvncserver/websockets.c b/libvncserver/websockets.c
|
|
|
ae49b1 |
index 8cd96d38..937f6d4d 100644
|
|
|
ae49b1 |
--- a/libvncserver/websockets.c
|
|
|
ae49b1 |
+++ b/libvncserver/websockets.c
|
|
|
ae49b1 |
@@ -88,6 +88,11 @@ typedef union ws_mask_s {
|
|
|
ae49b1 |
uint32_t u;
|
|
|
ae49b1 |
} ws_mask_t;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
+/* XXX: The union and the structs do not need to be named.
|
|
|
ae49b1 |
+ * We are working around a bug present in GCC < 4.6 which prevented
|
|
|
ae49b1 |
+ * it from recognizing anonymous structs and unions.
|
|
|
ae49b1 |
+ * See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4784
|
|
|
ae49b1 |
+ */
|
|
|
ae49b1 |
typedef struct __attribute__ ((__packed__)) ws_header_s {
|
|
|
ae49b1 |
unsigned char b0;
|
|
|
ae49b1 |
unsigned char b1;
|
|
|
ae49b1 |
@@ -95,13 +100,13 @@ typedef struct __attribute__ ((__packed__)) ws_header_s {
|
|
|
ae49b1 |
struct __attribute__ ((__packed__)) {
|
|
|
ae49b1 |
uint16_t l16;
|
|
|
ae49b1 |
ws_mask_t m16;
|
|
|
ae49b1 |
- };
|
|
|
ae49b1 |
+ } s16;
|
|
|
ae49b1 |
struct __attribute__ ((__packed__)) {
|
|
|
ae49b1 |
uint64_t l64;
|
|
|
ae49b1 |
ws_mask_t m64;
|
|
|
ae49b1 |
- };
|
|
|
ae49b1 |
+ } s64;
|
|
|
ae49b1 |
ws_mask_t m;
|
|
|
ae49b1 |
- };
|
|
|
ae49b1 |
+ } u;
|
|
|
ae49b1 |
} ws_header_t;
|
|
|
ae49b1 |
|
|
|
ae49b1 |
enum
|
|
|
ae49b1 |
@@ -792,11 +797,11 @@ webSocketsEncodeHybi(rfbClientPtr cl, const char *src, int len, char **dst)
|
|
|
ae49b1 |
sz = 2;
|
|
|
ae49b1 |
} else if (blen <= 65536) {
|
|
|
ae49b1 |
header->b1 = 0x7e;
|
|
|
ae49b1 |
- header->l16 = WS_HTON16((uint16_t)blen);
|
|
|
ae49b1 |
+ header->u.s16.l16 = WS_HTON16((uint16_t)blen);
|
|
|
ae49b1 |
sz = 4;
|
|
|
ae49b1 |
} else {
|
|
|
ae49b1 |
header->b1 = 0x7f;
|
|
|
ae49b1 |
- header->l64 = WS_HTON64(blen);
|
|
|
ae49b1 |
+ header->u.s64.l64 = WS_HTON64(blen);
|
|
|
ae49b1 |
sz = 10;
|
|
|
ae49b1 |
}
|
|
|
ae49b1 |
|
|
|
ae49b1 |
--
|
|
|
ae49b1 |
2.26.2
|
|
|
ae49b1 |
|