on master help sign in
Rework the assert statements, spotted by FlexeLint
commit226e10bfdc01cf209dd276a38ec74d621d0a5280 authorNeil Mitchell <ndmitchell@gmail.com> dateWed 30 Nov 2016, 19:08 (10 years ago) parentac6ebb6
1 file changed+3−7
cbits/hexml.c+3−7
cbits/hexml.c+3−7
@@ -14,7 +14,7 @@ static inline int end(str s) { return s.start + s.length; }
1414
1515static inline str start_length(int32_t start, int32_t length)
1616{
17− if (start < 0 || length < 0) assert(0);
17+ assert(start >= 0 && length >= 0);
1818 str res;
1919 res.start = start;
2020 res.length = length;
@@ -87,16 +87,12 @@ static inline void render_char(render* r, char c)
8787
8888static inline void bound(const char* msg, int index, int mn, int mx)
8989{
90− if (index < mn || index > mx)
91− {
92− //printf("Bounds checking failed %s, got %i, which should be in %i:%i\n", msg, index, mn, mx);
93− assert(0);
94− }
90+ assert(index >= mn && index <= mx);
9591}
9692
9793static inline void bound_str(const char* msg, str s, int mn, int mx)
9894{
99− if (s.length < 0) assert(0);
95+ assert(s.length >= 0);
10096 bound(msg, s.start, mn, mx);
10197 bound(msg, end(s), mn, mx);
10298}