Ignore boring return codes properly.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 14 Mar 2012 18:50:01 +0000 (18:50 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 14 Mar 2012 21:09:25 +0000 (21:09 +0000)
The warning about variables assigned values and then ignored is useful,
as are warnings about ignored return codes sometimes.  But sometimes
ignoring things really is the right answer.

client/tripectl.c
common/util.h
pkstream/pkstream.c
proxy/tripe-mitm.c
server/tun-bsd.c
server/tun-linux.c
server/tun-unet.c

index f818de8..438edf3 100644 (file)
@@ -65,7 +65,6 @@
 #include "util.h"
 
 #undef sun
-#define IGNORE(x) do if (x); while (0)
 
 /*----- Data structures ---------------------------------------------------*/
 
index 1928c04..acdc0f6 100644 (file)
   extern "C" {
 #endif
 
+/*----- Macros ------------------------------------------------------------*/
+
+/* --- @IGNORE@ --- *
+ *
+ * Arguments:  @expr@ = an expression whose value is to be ignored
+ *
+ * Use:                Ignores the value of an expression, even if compilers want
+ *             us not to.
+ */
+
+#define IGNORE(expr) do { if (expr) ; } while (0)
+
 /*----- Functions provided ------------------------------------------------*/
 
 /* --- @u_quotify@ --- *
index 665b80e..d431b82 100644 (file)
@@ -54,6 +54,8 @@
 #include <mLib/sel.h>
 #include <mLib/selpk.h>
 
+#include "util.h"
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct pk {
@@ -120,7 +122,6 @@ static void rdtcp(octet *b, size_t sz, pkbuf *pk, size_t *k, void *vp)
 {
   pkstream *p = vp;
   size_t pksz;
-  int hunoz;
 
   if (!sz) {
     doclose(p);
@@ -128,7 +129,7 @@ static void rdtcp(octet *b, size_t sz, pkbuf *pk, size_t *k, void *vp)
   }
   pksz = LOAD16(b);
   if (pksz + 2 == sz) {
-    hunoz = write(fd_udp, b + 2, pksz);
+    IGNORE(write(fd_udp, b + 2, pksz));
     selpk_want(&p->p, 2);
   } else {
     selpk_want(&p->p, pksz + 2);
index 3686b7b..4b0e447 100644 (file)
@@ -67,6 +67,8 @@
 #include <catacomb/rand.h>
 #include <catacomb/rc4.h>
 
+#include "util.h"
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct peer {
@@ -406,10 +408,8 @@ static void adddelay(filter *f, unsigned ac, char **av)
 
 static void dosend(filter *f, const octet *buf, size_t sz)
 {
-  int hunoz;
-
   printf("send to `%s'\n", f->p_to->name);
-  hunoz = write(f->p_to->sf.fd, buf, sz);
+  IGNORE(write(f->p_to->sf.fd, buf, sz));
 }
 
 static void addsend(filter *f, unsigned ac, char **av)
index b945c7d..2c87299 100644 (file)
@@ -119,13 +119,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
-  int hunoz;
-
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-bsd: inject decrypted packet");
     trace_block(T_PACKET, "tun-bsd: packet contents", BBASE(b), BLEN(b));
   })
-  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
+  IGNORE(write(t->f.fd, BBASE(b), BLEN(b)));
 }
 
 /* --- @t_destroy@ --- *
index 3345174..10456e3 100644 (file)
@@ -125,13 +125,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
-  int hunoz;
-
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-linux: inject decrypted packet");
     trace_block(T_PACKET, "tunnel: packet contents", BBASE(b), BLEN(b));
   })
-  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
+  IGNORE(write(t->f.fd, BBASE(b), BLEN(b)));
 }
 
 /* --- @t_destroy@ --- *
index 719830b..19dc5e6 100644 (file)
@@ -125,13 +125,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
-  int hunoz;
-
   IF_TRACING(T_TUNNEL, {
     trace(T_TUNNEL, "tun-unet: inject decrypted packet");
     trace_block(T_PACKET, "tun-unet: packet contents", BBASE(b), BLEN(b));
   })
-  hunoz = write(t->f.fd, BBASE(b), BLEN(b));
+  IGNORE(write(t->f.fd, BBASE(b), BLEN(b)));
 }
 
 /* --- @t_destroy@ --- *