diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2016-05-12 11:54:34 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2016-05-12 11:54:34 -0700 |
commit | fa338b70a602d9f5657528d0322535959a92d4b0 (patch) | |
tree | a7ec8b8d61a1ff3657aff99316ec51a8b81726ad /upb/pb/encoder.c | |
parent | e16ed470be7d0d459e85e1d7b43893358a625d34 (diff) |
Added UPB_ASSERT() that helps avoid unused var warnings.
* Added UPB_ASSERT() that helps avoid unused var warnings.
* Addressed PR comments.
* Fixed assert in the JIT.
Diffstat (limited to 'upb/pb/encoder.c')
-rw-r--r-- | upb/pb/encoder.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/upb/pb/encoder.c b/upb/pb/encoder.c index 8f974a3..780425d 100644 --- a/upb/pb/encoder.c +++ b/upb/pb/encoder.c @@ -128,7 +128,7 @@ struct upb_pb_encoder { /* TODO(haberman): handle pushback */ static void putbuf(upb_pb_encoder *e, const char *buf, size_t len) { size_t n = upb_bytessink_putbuf(e->output_, e->subc, buf, len, NULL); - UPB_ASSERT_VAR(n, n == len); + UPB_ASSERT(n == len); } static upb_pb_encoder_segment *top(upb_pb_encoder *e) { @@ -168,7 +168,7 @@ static bool reserve(upb_pb_encoder *e, size_t bytes) { /* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have * previously called reserve() with at least this many bytes. */ static void encoder_advance(upb_pb_encoder *e, size_t bytes) { - assert((size_t)(e->limit - e->ptr) >= bytes); + UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes); e->ptr += bytes; } @@ -203,7 +203,7 @@ static bool encode_bytes(upb_pb_encoder *e, const void *data, size_t len) { * length. */ static void accumulate(upb_pb_encoder *e) { size_t run_len; - assert(e->ptr >= e->runbegin); + UPB_ASSERT(e->ptr >= e->runbegin); run_len = e->ptr - e->runbegin; e->segptr->seglen += run_len; top(e)->msglen += run_len; @@ -558,7 +558,8 @@ upb_pb_encoder *upb_pb_encoder_create(upb_env *env, const upb_handlers *h, e->ptr = e->buf; /* If this fails, increase the value in encoder.h. */ - assert(upb_env_bytesallocated(env) - size_before <= UPB_PB_ENCODER_SIZE); + UPB_ASSERT_DEBUGVAR(upb_env_bytesallocated(env) - size_before <= + UPB_PB_ENCODER_SIZE); return e; } |