diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-08-21 10:56:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-08-21 11:22:42 -0400 |
commit | 7bc25b5a78bfaa0b04eb55470a2b36cf9a466d72 (patch) | |
tree | 74ff4c45d86d60caab1f021681b258c377d730ca /src/common/container.c | |
parent | c43e45d0eaac67caa5b6c1449fb1e4931a410933 (diff) | |
download | tor-7bc25b5a78bfaa0b04eb55470a2b36cf9a466d72.tar.gz tor-7bc25b5a78bfaa0b04eb55470a2b36cf9a466d72.zip |
Avoid performing an assert on an always-true value
This was freaking out coverity.
[CID 743379]
Diffstat (limited to 'src/common/container.c')
-rw-r--r-- | src/common/container.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c index 54f041bac7..7f02dec550 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -66,11 +66,17 @@ smartlist_ensure_capacity(smartlist_t *sl, int size) #define MAX_CAPACITY (INT_MAX) #else #define MAX_CAPACITY (int)((SIZE_MAX / (sizeof(void*)))) +#define ASSERT_CAPACITY #endif if (size > sl->capacity) { int higher = sl->capacity; if (PREDICT_UNLIKELY(size > MAX_CAPACITY/2)) { +#ifdef ASSERT_CAPACITY + /* We don't include this assertion when MAX_CAPACITY == INT_MAX, + * since int size; (size <= INT_MAX) makes analysis tools think we're + * doing something stupid. */ tor_assert(size <= MAX_CAPACITY); +#endif higher = MAX_CAPACITY; } else { while (size > higher) @@ -80,6 +86,8 @@ smartlist_ensure_capacity(smartlist_t *sl, int size) sl->list = tor_reallocarray(sl->list, sizeof(void *), ((size_t)sl->capacity)); } +#undef ASSERT_CAPACITY +#undef MAX_CAPACITY } /** Append element to the end of the list. */ |