diff mbox series

[v2,for-3.2,v2,17/30] slirp: replace a DEBUG block with WITH_ICMP_ERROR_MSG

Message ID 20181121220647.18844-18-marcandre.lureau@redhat.com
State New
Headers show
Series slirp: make it again a standalone project | expand

Commit Message

Marc-André Lureau Nov. 21, 2018, 10:06 p.m. UTC
icmp_send_error() doesnt actually log messages when DEBUG is enabled.
Let's use a different define that describes better the tweaked
behaviour of the function, and avoid uncompiled code.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 slirp/ip_icmp.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Samuel Thibault Nov. 21, 2018, 10:31 p.m. UTC | #1
Marc-André Lureau, le jeu. 22 nov. 2018 02:06:34 +0400, a ecrit:
> icmp_send_error() doesnt actually log messages when DEBUG is enabled.
> Let's use a different define that describes better the tweaked
> behaviour of the function, and avoid uncompiled code.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Applied to my tree, thanks!
diff mbox series

Patch

diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index af11cfcefe..6c7e375ff8 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -34,6 +34,10 @@ 
 #include "slirp.h"
 #include "ip_icmp.h"
 
+#ifndef WITH_ICMP_ERROR_MSG
+#define WITH_ICMP_ERROR_MSG 0
+#endif
+
 /* The message sent when emulating PING */
 /* Be nice and tell them it's just a pseudo-ping packet */
 static const char icmp_ping_msg[] = "This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
@@ -319,8 +323,7 @@  icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
   HTONS(icp->icmp_ip.ip_id);
   HTONS(icp->icmp_ip.ip_off);
 
-#ifdef DEBUG
-  if(message) {           /* DEBUG : append message to ICMP packet */
+  if (message && WITH_ICMP_ERROR_MSG) { /* append message to ICMP packet */
     int message_len;
     char *cpnt;
     message_len=strlen(message);
@@ -329,7 +332,6 @@  icmp_send_error(struct mbuf *msrc, u_char type, u_char code, int minsize,
     memcpy(cpnt, message, message_len);
     m->m_len+=message_len;
   }
-#endif
 
   icp->icmp_cksum = 0;
   icp->icmp_cksum = cksum(m, m->m_len);