aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2011-11-25 10:56:18 +0100
committerDaniel Stenberg <daniel@haxx.se>2011-11-25 10:56:18 +0100
commit4a4d04446da7b11c7c360d18bfd115a573001cde (patch)
treed2c74429347b7f5370abdf1bc883be5e9270f68b /lib
parentb9223a17b8a500c88e8c5eddec7b261cf73514fc (diff)
telnet: fix macros to allow proper semicolon use
Macros that look like function calls need to be made so that we can use semicolons properly for indentation and for reducing the risk for mistakes when using them.
Diffstat (limited to 'lib')
-rw-r--r--lib/telnet.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/telnet.c b/lib/telnet.c
index 0b63b12ae..3e9e1a306 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -75,12 +75,17 @@
#define SUBBUFSIZE 512
-#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer;
-#define CURL_SB_TERM(x) { x->subend = x->subpointer; CURL_SB_CLEAR(x); }
-#define CURL_SB_ACCUM(x,c) \
- if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) { \
- *x->subpointer++ = (c); \
- }
+#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer
+#define CURL_SB_TERM(x) \
+ do { \
+ x->subend = x->subpointer; \
+ CURL_SB_CLEAR(x); \
+ } while(0)
+#define CURL_SB_ACCUM(x,c) \
+ do { \
+ if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) \
+ *x->subpointer++ = (c); \
+ } while(0)
#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
#define CURL_SB_PEEK(x) ((*x->subpointer)&0xff)
@@ -1014,28 +1019,28 @@ static void sendsuboption(struct connectdata *conn, int option)
switch (option) {
case CURL_TELOPT_NAWS:
/* We prepare data to be sent */
- CURL_SB_CLEAR(tn)
- CURL_SB_ACCUM(tn,CURL_IAC)
- CURL_SB_ACCUM(tn,CURL_SB)
- CURL_SB_ACCUM(tn,CURL_TELOPT_NAWS)
+ CURL_SB_CLEAR(tn);
+ CURL_SB_ACCUM(tn, CURL_IAC);
+ CURL_SB_ACCUM(tn, CURL_SB);
+ CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS);
/* We must deal either with litte or big endien processors */
/* Window size must be sent according to the 'network order' */
x=htons(tn->subopt_wsx);
y=htons(tn->subopt_wsy);
uc1 = (unsigned char*)&x;
uc2 = (unsigned char*)&y;
- CURL_SB_ACCUM(tn,uc1[0])
- CURL_SB_ACCUM(tn,uc1[1])
- CURL_SB_ACCUM(tn,uc2[0])
- CURL_SB_ACCUM(tn,uc2[1])
-
- CURL_SB_ACCUM(tn,CURL_IAC)
- CURL_SB_ACCUM(tn,CURL_SE)
- CURL_SB_TERM(tn)
- /* data suboption is now ready */
-
- printsub(data, '>', (unsigned char *)tn->subbuffer+2,
- CURL_SB_LEN(tn)-2);
+ CURL_SB_ACCUM(tn, uc1[0]);
+ CURL_SB_ACCUM(tn, uc1[1]);
+ CURL_SB_ACCUM(tn, uc2[0]);
+ CURL_SB_ACCUM(tn, uc2[1]);
+
+ CURL_SB_ACCUM(tn, CURL_IAC);
+ CURL_SB_ACCUM(tn, CURL_SE);
+ CURL_SB_TERM(tn);
+ /* data suboption is now ready */
+
+ printsub(data, '>', (unsigned char *)tn->subbuffer+2,
+ CURL_SB_LEN(tn)-2);
/* we send the header of the suboption... */
bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer, 3);