improve comments
authorChristian Grothoff <christian@grothoff.org>
Mon, 9 Jan 2017 16:48:52 +0000 (17:48 +0100)
committerChristian Grothoff <christian@grothoff.org>
Mon, 9 Jan 2017 20:18:49 +0000 (21:18 +0100)
src/cadet/cadet.h
src/cadet/cadet_common.c

index 049f3a85a729a1264ba537b4aa5dada0a9eba882..f3f6fb6b4a5f730943561bfbb6b25c72d1e57d79 100644 (file)
@@ -67,10 +67,16 @@ extern "C"
 #define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI        0x80000000
 #define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV       0xB0000000
 
-#define HIGH_PID                                0xFFFF0000
-#define LOW_PID                                 0x0000FFFF
+#define HIGH_PID                                0xFF000000
+#define LOW_PID                                 0x00FFFFFF
 
-#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID)
+/**
+ * Test if the two PIDs (of type `uint32_t`) are in the range where we
+ * have to worry about overflows.  This is the case when @a pid is
+ * large and @a max is small, useful when comparing @a pid smaller
+ * than @a max.
+ */
+#define PID_OVERFLOW(pid, max) (((pid) > HIGH_PID) && ((max) < LOW_PID))
 
 /******************************************************************************/
 /**************************        MESSAGES      ******************************/
index a9d9a35be7dc40db20959bb257992dd9d5b98bde..20ee7e5c944cdf53e064dc3d410990e9f91dd1ae 100644 (file)
@@ -51,11 +51,20 @@ GC_f2s (int fwd)
   }
 }
 
+
+/**
+ * Test if @a bigger is larger than @a smaller.
+ * Considers the case that @a bigger just overflowed
+ * and is thus tiny while @a smaller is still below
+ * `UINT32_MAX`.
+ */
 int
-GC_is_pid_bigger (uint32_t bigger, uint32_t smaller)
+GC_is_pid_bigger (uint32_t bigger,
+                 uint32_t smaller)
 {
-    return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) ||
-            (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller)));
+    return (PID_OVERFLOW (smaller, bigger) ||
+            ( (bigger > smaller) &&
+             (! PID_OVERFLOW (bigger, smaller))) );
 }