From 30fe2576918ff07116e4efa6c920ba79c8e646a3 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Sat, 25 Aug 2012 20:36:58 +0100 Subject: [PATCH] Style fixes. Printing error message before fatal error. --- examples/chat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/chat.c b/examples/chat.c index a2f85f87..b7f5d801 100644 --- a/examples/chat.c +++ b/examples/chat.c @@ -122,7 +122,7 @@ static int handle_jsonp(struct mg_connection *conn, if (cb[0] != '\0') { mg_printf(conn, "%s(", cb); } - + return cb[0] == '\0' ? 0 : 1; } @@ -369,8 +369,10 @@ int main(void) { srand((unsigned) time(0)); // Setup and start Mongoose - ctx = mg_start(&event_handler, NULL, options); - assert(ctx != NULL); + if ((ctx = mg_start(&event_handler, NULL, options)) == NULL) { + printf("%s\n", "Cannot start chat server, fatal exit"); + exit(EXIT_FAILURE); + } // Wait until enter is pressed, then exit printf("Chat server started on ports %s, press enter to quit.\n",