From 5eba344a848b591b0553924e41983a53a2f2b798 Mon Sep 17 00:00:00 2001
From: David Girault <david@dhgirault.fr>
Date: Tue, 6 Jun 2017 19:04:05 +0200
Subject: [PATCH 1/5] altcp_tls_mbedtls: fix log messages by include a `\n`

---
 src/apps/altcp_tls/altcp_tls_mbedtls.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/apps/altcp_tls/altcp_tls_mbedtls.c b/src/apps/altcp_tls/altcp_tls_mbedtls.c
index ebca8855..8f62ba06 100644
--- a/src/apps/altcp_tls/altcp_tls_mbedtls.c
+++ b/src/apps/altcp_tls/altcp_tls_mbedtls.c
@@ -275,7 +275,7 @@ altcp_mbedtls_lower_recv_process(struct altcp_pcb *conn, altcp_mbedtls_state_t *
       return ERR_OK;
     }
     if (ret != 0) {
-      LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_handshake failed: %d", ret));
+      LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_handshake failed: %d\n", ret));
       /* handshake failed, connection has to be closed */
       conn->recv(conn->arg, conn, NULL, ERR_OK);
       if (altcp_close(conn->inner_conn) != ERR_OK) {
@@ -366,13 +366,13 @@ altcp_mbedtls_handle_rx_appldata(struct altcp_pcb *conn, altcp_mbedtls_state_t *
     if (ret < 0) {
       if (ret == MBEDTLS_ERR_SSL_CLIENT_RECONNECT) {
         /* client is initiating a new connection using the same source port -> close connection or make handshake */
-        LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("new connection on same source port"));
+        LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("new connection on same source port\n"));
         LWIP_ASSERT("TODO: new connection on same source port, close this connection", 0);
       } else if ((ret != MBEDTLS_ERR_SSL_WANT_READ) && (ret != MBEDTLS_ERR_SSL_WANT_WRITE)) {
         if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
-          LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("connection was closed gracefully"));
+          LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("connection was closed gracefully\n"));
         } else if (ret == MBEDTLS_ERR_NET_CONN_RESET) {
-          LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("connection was reset by peer"));
+          LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("connection was reset by peer\n"));
         }
         pbuf_free(buf);
         return ERR_OK;
@@ -574,7 +574,7 @@ altcp_mbedtls_setup(void *conf, struct altcp_pcb *conn, struct altcp_pcb *inner_
   mbedtls_ssl_init(&state->ssl_context);
   ret = mbedtls_ssl_setup(&state->ssl_context, &config->conf);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_setup failed"));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_setup failed\n"));
     /* @todo: convert 'ret' to err_t */
     altcp_mbedtls_free(conf, state);
     return ERR_MEM;
@@ -658,7 +658,7 @@ altcp_tls_create_config(int is_server)
   /* Seed the RNG */
   ret = mbedtls_ctr_drbg_seed(&conf->ctr_drbg, ALTCP_MBEDTLS_RNG_FN, &conf->entropy, ALTCP_MBEDTLS_ENTROPY_PTR, ALTCP_MBEDTLS_ENTROPY_LEN);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ctr_drbg_seed failed: %d", ret));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ctr_drbg_seed failed: %d\n", ret));
     altcp_mbedtls_free_config(conf);
     return NULL;
   }
@@ -667,7 +667,7 @@ altcp_tls_create_config(int is_server)
   ret = mbedtls_ssl_config_defaults(&conf->conf, is_server ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT,
     MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_config_defaults failed: %d", ret));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_config_defaults failed: %d\n", ret));
     altcp_mbedtls_free_config(conf);
     return NULL;
   }
@@ -709,14 +709,14 @@ altcp_tls_create_config_server_privkey_cert(const u8_t *privkey, size_t privkey_
   /* Load the certificates and private key */
   ret = mbedtls_x509_crt_parse(&srvcert, cert, cert_len);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_x509_crt_parse failed: %d", ret));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_x509_crt_parse failed: %d\n", ret));
     altcp_mbedtls_free_config(conf);
     return NULL;
   }
 
   ret = mbedtls_pk_parse_key(&pkey, (const unsigned char *) privkey, privkey_len, privkey_pass, privkey_pass_len);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_pk_parse_public_key failed: %d", ret));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_pk_parse_public_key failed: %d\n", ret));
     altcp_mbedtls_free_config(conf);
     return NULL;
   }
@@ -724,7 +724,7 @@ altcp_tls_create_config_server_privkey_cert(const u8_t *privkey, size_t privkey_
   mbedtls_ssl_conf_ca_chain(&conf->conf, srvcert.next, NULL);
   ret = mbedtls_ssl_conf_own_cert(&conf->conf, &srvcert, &pkey);
   if (ret != 0) {
-    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_conf_own_cert failed: %d", ret));
+    LWIP_DEBUGF(ALTCP_MBEDTLS_DEBUG, ("mbedtls_ssl_conf_own_cert failed: %d\n", ret));
     altcp_mbedtls_free_config(conf);
     return NULL;
   }
-- 
2.11.0

