chiark / gitweb /
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 f818de8d8c91f8a2fb765e9e709907825109675e..438edf376bf6dad65915e2eaf25a0c4655d14a0f 100644 (file)
@@ -65,7 +65,6 @@
 #include "util.h"
 
 #undef sun
 #include "util.h"
 
 #undef sun
-#define IGNORE(x) do if (x); while (0)
 
 /*----- Data structures ---------------------------------------------------*/
 
 
 /*----- Data structures ---------------------------------------------------*/
 
index 1928c0428770a29607fa0377190aa66bdae54676..acdc0f6e909d79664321620ee2434fa48ccc2d5c 100644 (file)
   extern "C" {
 #endif
 
   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@ --- *
 /*----- Functions provided ------------------------------------------------*/
 
 /* --- @u_quotify@ --- *
index 665b80ea7753ae99052046bff01935c230c43585..d431b8201e64c1c10d5f96afe8e2514c9fa8567f 100644 (file)
@@ -54,6 +54,8 @@
 #include <mLib/sel.h>
 #include <mLib/selpk.h>
 
 #include <mLib/sel.h>
 #include <mLib/selpk.h>
 
+#include "util.h"
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct pk {
 /*----- 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;
 {
   pkstream *p = vp;
   size_t pksz;
-  int hunoz;
 
   if (!sz) {
     doclose(p);
 
   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) {
   }
   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);
     selpk_want(&p->p, 2);
   } else {
     selpk_want(&p->p, pksz + 2);
index 3686b7ba4e4691ee73fabb3a8f22b97a3a16b23d..4b0e44700f260ca6b926ecf332077b0dc9059a69 100644 (file)
@@ -67,6 +67,8 @@
 #include <catacomb/rand.h>
 #include <catacomb/rc4.h>
 
 #include <catacomb/rand.h>
 #include <catacomb/rc4.h>
 
+#include "util.h"
+
 /*----- Data structures ---------------------------------------------------*/
 
 typedef struct peer {
 /*----- 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)
 {
 
 static void dosend(filter *f, const octet *buf, size_t sz)
 {
-  int hunoz;
-
   printf("send to `%s'\n", f->p_to->name);
   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)
 }
 
 static void addsend(filter *f, unsigned ac, char **av)
index b945c7dd92ecfd57afdf2c8a42d6436047c667e5..2c872997f7a79e82ea70b522f24814060f86f1e8 100644 (file)
@@ -119,13 +119,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
 
 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));
   })
   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@ --- *
 }
 
 /* --- @t_destroy@ --- *
index 33451746fd9ff9adbff726f5d06ca0d299c9764e..10456e352c54c27050291b1ac898fa4c57c52b34 100644 (file)
@@ -125,13 +125,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
 
 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));
   })
   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@ --- *
 }
 
 /* --- @t_destroy@ --- *
index 719830bf113acae1dca79dd4286874b2aa91af89..19dc5e6084f385e0a7397745ada6d5b04b502823 100644 (file)
@@ -125,13 +125,11 @@ static tunnel *t_create(peer *p, int fd, char **ifn)
 
 static void t_inject(tunnel *t, buf *b)
 {
 
 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));
   })
   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@ --- *
 }
 
 /* --- @t_destroy@ --- *