git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailinfo.c: move side-effects outside of assert
@ 2016-12-17 19:54 Kyle J. McKay
  2016-12-19 17:45 ` Johannes Schindelin
  2016-12-19 20:03 ` Jeff King
  0 siblings, 2 replies; 18+ messages in thread
From: Kyle J. McKay @ 2016-12-17 19:54 UTC (permalink / raw)
  To: Jonathan Tan, Junio C Hamano; +Cc: Git mailing list

Since 6b4b013f18 (mailinfo: handle in-body header continuations,
2016-09-20, v2.11.0) mailinfo.c has contained new code with an
assert of the form:

	assert(call_a_function(...))

The function in question, check_header, has side effects.  This
means that when NDEBUG is defined during a release build the
function call is omitted entirely, the side effects do not
take place and tests (fortunately) start failing.

Move the function call outside of the assert and assert on
the result of the function call instead so that the code
still works properly in a release build and passes the tests.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
---

Notes:
    Please include this PATCH in 2.11.x maint

 mailinfo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mailinfo.c b/mailinfo.c
index 2fb3877e..47442fb5 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -708,9 +708,12 @@ static int is_scissors_line(const char *line)
 
 static void flush_inbody_header_accum(struct mailinfo *mi)
 {
+	int okay;
+
 	if (!mi->inbody_header_accum.len)
 		return;
-	assert(check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0));
+	okay = check_header(mi, &mi->inbody_header_accum, mi->s_hdr_data, 0);
+	assert(okay);
 	strbuf_reset(&mi->inbody_header_accum);
 }
 
---

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-12-22 17:57 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-17 19:54 [PATCH] mailinfo.c: move side-effects outside of assert Kyle J. McKay
2016-12-19 17:45 ` Johannes Schindelin
2016-12-19 20:03 ` Jeff King
2016-12-19 20:38   ` Kyle J. McKay
2016-12-19 20:54     ` Jonathan Tan
2016-12-19 21:01       ` Junio C Hamano
2016-12-19 23:13         ` [PATCH v2] " Kyle J. McKay
2016-12-19 23:26           ` Junio C Hamano
2016-12-19 23:54             ` [PATCH v3] " Kyle J. McKay
2016-12-20 14:12     ` [PATCH] " Johannes Schindelin
2016-12-20 16:45       ` Jeff King
2016-12-21  5:54         ` Kyle J. McKay
2016-12-21 15:55           ` Jeff King
2016-12-22  2:21             ` Kyle J. McKay
2016-12-22  3:34               ` Jeff King
2016-12-22 17:57                 ` Junio C Hamano
2016-12-22  3:53               ` Kyle J. McKay
2016-12-22  3:59                 ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).