]> granicus.if.org Git - gc/commitdiff
Define CORD_ec_append macro to expression instead of block (cord)
authorIvan Maidanski <ivmai@mail.ru>
Sat, 22 Dec 2012 19:09:00 +0000 (23:09 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 22 Dec 2012 19:09:00 +0000 (23:09 +0400)
(code refactoring)

* include/ec.h (CORD_ec_init): Cast result to void (no return value).
* include/ec.h (CORD_ec_append): Replace block with void expression;
remove redundant parentheses.

include/ec.h

index b88e70356df5737672f79af26c692a92f53a9ed0..30806ed2f9b0cc40c966aff83bd32838627ceb58 100644 (file)
@@ -52,16 +52,14 @@ void CORD_ec_flush_buf(CORD_ec x);
 # define CORD_ec_to_cord(x) (CORD_ec_flush_buf(x), (x)[0].ec_cord)
 
 /* Initialize an extensible cord. */
-# define CORD_ec_init(x) ((x)[0].ec_cord = 0, (x)[0].ec_bufptr = (x)[0].ec_buf)
+#define CORD_ec_init(x) \
+                ((x)[0].ec_cord = 0, (void)((x)[0].ec_bufptr = (x)[0].ec_buf))
 
 /* Append a character to an extensible cord.    */
-# define CORD_ec_append(x, c) \
-    {  \
-        if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \
-                CORD_ec_flush_buf(x); \
-        } \
-        *((x)[0].ec_bufptr)++ = (c); \
-    }
+#define CORD_ec_append(x, c) \
+                (((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ ? \
+                        (CORD_ec_flush_buf(x), 0) : 0), \
+                 (void)(*(x)[0].ec_bufptr++ = (c)))
 
 /* Append a cord to an extensible cord.  Structure remains shared with  */
 /* original.                                                            */