summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-10-01 12:42:26 -0400
committerNick Mathewson <nickm@torproject.org>2019-10-01 13:01:20 -0400
commitf17591b8e504af9e088bd9df900639c83f5300fe (patch)
tree17cabaefaeb0539f74355e350c894ee31aa9e463
parent6f3f93d86c03a7e38e6ba5b64e487aebcd0642bc (diff)
downloadtor-f17591b8e504af9e088bd9df900639c83f5300fe.tar.gz
tor-f17591b8e504af9e088bd9df900639c83f5300fe.zip
Rename max_in_sl to max_in_u16_sl, and expose it as STATIC.
Since we want to make this function slightly more visible for testing purposes, it needs a better name.
-rw-r--r--src/lib/dispatch/.may_include1
-rw-r--r--src/lib/dispatch/dispatch_cfg.h6
-rw-r--r--src/lib/dispatch/dispatch_new.c10
3 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/dispatch/.may_include b/src/lib/dispatch/.may_include
index 7f2df5859f..884f4c0dbc 100644
--- a/src/lib/dispatch/.may_include
+++ b/src/lib/dispatch/.may_include
@@ -8,3 +8,4 @@ lib/dispatch/*.h
lib/intmath/*.h
lib/log/*.h
lib/malloc/*.h
+lib/testsupport/*.h \ No newline at end of file
diff --git a/src/lib/dispatch/dispatch_cfg.h b/src/lib/dispatch/dispatch_cfg.h
index 61fade7240..348dce8d40 100644
--- a/src/lib/dispatch/dispatch_cfg.h
+++ b/src/lib/dispatch/dispatch_cfg.h
@@ -8,6 +8,7 @@
#define TOR_DISPATCH_CFG_H
#include "lib/dispatch/msgtypes.h"
+#include "lib/testsupport/testsupport.h"
/**
* A "dispatch_cfg" is the configuration used to set up a dispatcher.
@@ -36,4 +37,9 @@ int dcfg_add_recv(dispatch_cfg_t *cfg, message_id_t msg,
void dcfg_free_(dispatch_cfg_t *cfg);
+#ifdef DISPATCH_NEW_PRIVATE
+struct smartlist_t;
+STATIC int max_in_u16_sl(const struct smartlist_t *sl, int dflt);
+#endif
+
#endif /* !defined(TOR_DISPATCH_CFG_H) */
diff --git a/src/lib/dispatch/dispatch_new.c b/src/lib/dispatch/dispatch_new.c
index b89ef43ea7..4467813064 100644
--- a/src/lib/dispatch/dispatch_new.c
+++ b/src/lib/dispatch/dispatch_new.c
@@ -9,6 +9,7 @@
* \brief Code to construct a dispatch_t from a dispatch_cfg_t.
**/
+#define DISPATCH_NEW_PRIVATE
#define DISPATCH_PRIVATE
#include "orconfig.h"
@@ -26,8 +27,8 @@
/** Given a smartlist full of (possibly NULL) pointers to uint16_t values,
* return the largest value, or dflt if the list is empty. */
-static int
-max_in_sl(const smartlist_t *sl, int dflt)
+STATIC int
+max_in_u16_sl(const smartlist_t *sl, int dflt)
{
uint16_t *maxptr = NULL;
SMARTLIST_FOREACH_BEGIN(sl, uint16_t *, u) {
@@ -118,11 +119,12 @@ dispatch_new(const dispatch_cfg_t *cfg)
smartlist_len(cfg->recv_by_msg)) + 1;
/* Any channel that any message has counts towards the number of channels. */
- const size_t n_chans = (size_t) MAX(1, max_in_sl(cfg->chan_by_msg,0)) + 1;
+ const size_t n_chans = (size_t)
+ MAX(1, max_in_u16_sl(cfg->chan_by_msg,0)) + 1;
/* Any type that a message has, or that has functions, counts towards
* the number of types. */
- const size_t n_types = (size_t) MAX(max_in_sl(cfg->type_by_msg,0),
+ const size_t n_types = (size_t) MAX(max_in_u16_sl(cfg->type_by_msg,0),
smartlist_len(cfg->fns_by_type)) + 1;
d->n_msgs = n_msgs;