Index: common/dataio.c
===================================================================
--- common/dataio.c	(révision 16932)
+++ common/dataio.c	(copie de travail)
@@ -57,6 +57,13 @@
 
 #include "dataio.h"
 
+
+#ifdef DEBUG
+#define DIO_DEBUG_ASSERT(check) fc_assert(check)
+#else
+#define DIO_DEBUG_ASSERT(check) /* Nothing. */
+#endif /* DEBUG */
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -202,7 +209,8 @@
   if (enough_space(dout, 1)) {
     uint8_t x = value;
 
-    fc_assert(sizeof(x) == 1);
+    DIO_DEBUG_ASSERT(sizeof(x) == 1);
+    DIO_DEBUG_ASSERT(0 <= value && value < (1 << (1 * 8)));
     memcpy(ADD_TO_POINTER(dout->dest, dout->current), &x, 1);
     dout->current++;
   }
@@ -216,7 +224,8 @@
   if (enough_space(dout, 2)) {
     uint16_t x = htons(value);
 
-    fc_assert(sizeof(x) == 2);
+    DIO_DEBUG_ASSERT(sizeof(x) == 2);
+    DIO_DEBUG_ASSERT(0 <= value && value < (1 << (2 * 8)));
     memcpy(ADD_TO_POINTER(dout->dest, dout->current), &x, 2);
     dout->current += 2;
   }
@@ -230,7 +239,8 @@
   if (enough_space(dout, 4)) {
     uint32_t x = htonl(value);
 
-    fc_assert(sizeof(x) == 4);
+    DIO_DEBUG_ASSERT(sizeof(x) == 4);
+    DIO_DEBUG_ASSERT(0 <= value && value < (1LL << (4 * 8)));
     memcpy(ADD_TO_POINTER(dout->dest, dout->current), &x, 4);
     dout->current += 4;
   }
@@ -241,11 +251,7 @@
 **************************************************************************/
 void dio_put_bool8(struct data_out *dout, bool value)
 {
-  if (value != TRUE && value != FALSE) {
-    log_error("Trying to put a non-boolean: %d", (int) value);
-    value = FALSE;
-  }
-
+  DIO_DEBUG_ASSERT(value == TRUE || value == FALSE);
   dio_put_uint8(dout, value ? 1 : 0);
 }
 
@@ -254,11 +260,7 @@
 **************************************************************************/
 void dio_put_bool32(struct data_out *dout, bool value)
 {
-  if (value != TRUE && value != FALSE) {
-    log_error("Trying to put a non-boolean: %d", (int) value);
-    value = FALSE;
-  }
-
+  DIO_DEBUG_ASSERT(value == TRUE || value == FALSE);
   dio_put_uint32(dout, value ? 1 : 0);
 }
 
@@ -346,8 +348,7 @@
   size_t max = (unsigned short)(-1);
 
   if (bits > max) {
-    fc_assert_msg(FALSE, "Bit string too long: %lu bits.",
-                  (unsigned long) bits);
+    log_error("Bit string too long: %lu bits.", (unsigned long) bits);
     bits = max;
   }
   bytes = (bits + 7) / 8;
@@ -411,7 +412,7 @@
     if (dest) {
       uint8_t x;
 
-      fc_assert(sizeof(x) == 1);
+      DIO_DEBUG_ASSERT(sizeof(x) == 1);
       memcpy(&x, ADD_TO_POINTER(din->src, din->current), 1);
       *dest = x;
     }
@@ -431,7 +432,7 @@
     if (dest) {
       uint16_t x;
 
-      fc_assert(sizeof(x) == 2);
+      DIO_DEBUG_ASSERT(sizeof(x) == 2);
       memcpy(&x, ADD_TO_POINTER(din->src, din->current), 2);
       *dest = ntohs(x);
     }
@@ -451,7 +452,7 @@
     if (dest) {
       uint32_t x;
 
-      fc_assert(sizeof(x) == 4);
+      DIO_DEBUG_ASSERT(sizeof(x) == 4);
       memcpy(&x, ADD_TO_POINTER(din->src, din->current), 4);
       *dest = ntohl(x);
     }
