gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 14/17: improve comments


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 14/17: improve comments
Date: Mon, 09 Jan 2017 21:19:20 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit f12a7fb70153815db528e9ff48088479b3313da3
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jan 9 17:48:52 2017 +0100

    improve comments
---
 src/cadet/cadet.h        | 12 +++++++++---
 src/cadet/cadet_common.c | 15 ++++++++++++---
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 049f3a85a..f3f6fb6b4 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -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      
******************************/
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index a9d9a35be..20ee7e5c9 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -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))) );
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]