aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-09 17:48:52 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-09 21:18:49 +0100
commitf12a7fb70153815db528e9ff48088479b3313da3 (patch)
tree904477a65c073c9a662c680700cb00678cce58e6 /src
parentd829597ee90dccffffd46a082372af6b35042130 (diff)
downloadgnunet-f12a7fb70153815db528e9ff48088479b3313da3.tar.gz
gnunet-f12a7fb70153815db528e9ff48088479b3313da3.zip
improve comments
Diffstat (limited to 'src')
-rw-r--r--src/cadet/cadet.h12
-rw-r--r--src/cadet/cadet_common.c15
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"
67#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000 67#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000
68#define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV 0xB0000000 68#define GNUNET_CADET_LOCAL_CHANNEL_ID_SERV 0xB0000000
69 69
70#define HIGH_PID 0xFFFF0000 70#define HIGH_PID 0xFF000000
71#define LOW_PID 0x0000FFFF 71#define LOW_PID 0x00FFFFFF
72 72
73#define PID_OVERFLOW(pid, max) (pid > HIGH_PID && max < LOW_PID) 73/**
74 * Test if the two PIDs (of type `uint32_t`) are in the range where we
75 * have to worry about overflows. This is the case when @a pid is
76 * large and @a max is small, useful when comparing @a pid smaller
77 * than @a max.
78 */
79#define PID_OVERFLOW(pid, max) (((pid) > HIGH_PID) && ((max) < LOW_PID))
74 80
75/******************************************************************************/ 81/******************************************************************************/
76/************************** MESSAGES ******************************/ 82/************************** 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)
51 } 51 }
52} 52}
53 53
54
55/**
56 * Test if @a bigger is larger than @a smaller.
57 * Considers the case that @a bigger just overflowed
58 * and is thus tiny while @a smaller is still below
59 * `UINT32_MAX`.
60 */
54int 61int
55GC_is_pid_bigger (uint32_t bigger, uint32_t smaller) 62GC_is_pid_bigger (uint32_t bigger,
63 uint32_t smaller)
56{ 64{
57 return (GNUNET_YES == PID_OVERFLOW (smaller, bigger) || 65 return (PID_OVERFLOW (smaller, bigger) ||
58 (bigger > smaller && GNUNET_NO == PID_OVERFLOW (bigger, smaller))); 66 ( (bigger > smaller) &&
67 (! PID_OVERFLOW (bigger, smaller))) );
59} 68}
60 69
61 70