summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-10-27 19:01:46 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-02 01:36:52 +0000
commit0515b88aa55e6e55d7ab2808d245fdd64f7863ff (patch)
tree3405571a2ffa6bd0b25b9dfc2643783f03ae7b44
parent246cbc402aabe5e971c43d1a21b66ab4c602f1cf (diff)
Avoid -Wdeclaration-after-statement warnings from static_assert
Some implementations of static_assert() define a new variable. Avoid warnings from those when calling static_assert() from a macro that may not be at the top of a new code block. ../../src/accept.c: In function 'IceAcceptConnection': ../../src/accept.c:159:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 159 | IceGetHeader (iceConn, 0, ICE_ByteOrder, | ^~~~~~~~~~~~ ../../src/connect.c: In function 'IceOpenConnection': ../../src/connect.c:254:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 254 | IceGetHeader (iceConn, 0, ICE_ByteOrder, | ^~~~~~~~~~~~ ../../src/connect.c:340:5: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] 340 | IceGetHeaderExtra (iceConn, 0, ICE_ConnectionSetup, | ^~~~~~~~~~~~~~~~~ [...etc...] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--include/X11/ICE/ICEmsg.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/X11/ICE/ICEmsg.h b/include/X11/ICE/ICEmsg.h
index 426b64c..b6bad13 100644
--- a/include/X11/ICE/ICEmsg.h
+++ b/include/X11/ICE/ICEmsg.h
@@ -128,6 +128,7 @@ extern IcePaAuthStatus _IcePaMagicCookie1Proc (
*/
#define IceGetHeader(_iceConn, _major, _minor, _headerSize, _msgType, _pMsg) \
+do { \
static_assert(_headerSize <= 1024, \
"Header size larger than ICE_OUTBUFSIZE"); \
if ((_iceConn->outbufptr + _headerSize) > _iceConn->outbufmax) \
@@ -137,9 +138,11 @@ extern IcePaAuthStatus _IcePaMagicCookie1Proc (
_pMsg->minorOpcode = _minor; \
_pMsg->length = (_headerSize - SIZEOF (iceMsg)) >> 3; \
_iceConn->outbufptr += _headerSize; \
- _iceConn->send_sequence++
+ _iceConn->send_sequence++; \
+} while (0)
#define IceGetHeaderExtra(_iceConn, _major, _minor, _headerSize, _extra, _msgType, _pMsg, _pData) \
+do { \
static_assert(_headerSize <= 1024, \
"Header size larger than ICE_OUTBUFSIZE"); \
if ((_iceConn->outbufptr + \
@@ -156,7 +159,8 @@ extern IcePaAuthStatus _IcePaMagicCookie1Proc (
_pMsg->majorOpcode = _major; \
_pMsg->minorOpcode = _minor; \
_pMsg->length = ((_headerSize - SIZEOF (iceMsg)) >> 3) + (_extra); \
- _iceConn->send_sequence++
+ _iceConn->send_sequence++; \
+} while (0)
#define IceSimpleMessage(_iceConn, _major, _minor) \
{ \