From christoph.mallon@gmx.de  Tue Feb 12 07:56:12 2013
Return-Path: <christoph.mallon@gmx.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id C4E316FC
	for <freebsd-gnats-submit@freebsd.org>; Tue, 12 Feb 2013 07:56:12 +0000 (UTC)
	(envelope-from christoph.mallon@gmx.de)
Received: from mout.gmx.net (mout.gmx.net [212.227.15.18])
	by mx1.freebsd.org (Postfix) with ESMTP id 72734AC7
	for <freebsd-gnats-submit@freebsd.org>; Tue, 12 Feb 2013 07:56:12 +0000 (UTC)
Received: from mailout-de.gmx.net ([10.1.76.33]) by mrigmx.server.lan
 (mrigmx001) with ESMTP (Nemesis) id 0MKwO6-1U5Aip0yTA-00057g for
 <FreeBSD-gnats-submit@freebsd.org>; Tue, 12 Feb 2013 08:56:11 +0100
Received: (qmail invoked by alias); 12 Feb 2013 07:56:10 -0000
Received: from p5B13243E.dip.t-dialin.net (EHLO rotluchs.lokal) [91.19.36.62]
  by mail.gmx.net (mp033) with SMTP; 12 Feb 2013 08:56:10 +0100
Received: from tron by rotluchs.lokal with local (Exim 4.80.1 (FreeBSD))
	(envelope-from <christoph.mallon@gmx.de>)
	id 1U5Ain-0006oh-FR
	for FreeBSD-gnats-submit@freebsd.org; Tue, 12 Feb 2013 08:56:09 +0100
Message-Id: <E1U5Ain-0006oh-FR@rotluchs.lokal>
Date: Tue, 12 Feb 2013 08:56:09 +0100
From: Christoph Mallon <christoph.mallon@gmx.de>
Reply-To: Christoph Mallon <christoph.mallon@gmx.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] uipc: Simplify and correct debug printing of flags.
X-Send-Pr-Version: 3.114
X-GNATS-Notify: Robert Watson <rwatson@FreeBSD.org>

>Number:         176051
>Category:       kern
>Synopsis:       [kernel] [patch] uipc: Simplify and correct debug printing of flags.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    brueffer
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 12 08:00:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Mon Mar 31 07:40:00 UTC 2014
>Originator:     Christoph Mallon
>Release:        FreeBSD 9.1-STABLE amd64
>Organization:
>Environment:


	
>Description:
The code to print uipc flags contains lots of code duplication and in
one case even prints wrong flag names (SS_* instead of SBS_*).

This patch simplifies and corrects the code by introducing two simple
macros to handle printing the flags.
>How-To-Repeat:
	
>Fix:
Please apply this patch.

--- 0001-uipc-Simplify-and-correct-debug-printing-of-flags.patch begins here ---
From 56e214f5eb0b4b54584f62d49a4b1e5cee335286 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon@gmx.de>
Date: Thu, 17 Jan 2013 13:39:31 +0100
Subject: [PATCH] uipc: Simplify and correct debug printing of flags.

This reduces code duplication and corrects printing the sb_states, which
were incorrectly shown as SS_*.

---
 sys/kern/uipc_debug.c | 255 +++++++++++++-------------------------------------
 1 file changed, 63 insertions(+), 192 deletions(-)

diff --git a/sys/kern/uipc_debug.c b/sys/kern/uipc_debug.c
index 57f4017..51e88aa 100644
--- a/sys/kern/uipc_debug.c
+++ b/sys/kern/uipc_debug.c
@@ -43,6 +43,11 @@ __FBSDID("$FreeBSD$");
 #ifdef DDB
 #include <ddb/ddb.h>
 
+#define PRINT_FLAG_INIT \
+    int sep = 2
+#define PRINT_FLAG(var, flag) \
+    ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep = 0) : (void)0)
+
 static void
 db_print_sotype(short so_type)
 {
@@ -77,149 +82,58 @@ db_print_sotype(short so_type)
 static void
 db_print_sooptions(short so_options)
 {
-	int comma;
-
-	comma = 0;
-	if (so_options & SO_DEBUG) {
-		db_printf("%sSO_DEBUG", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_ACCEPTCONN) {
-		db_printf("%sSO_ACCEPTCONN", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_REUSEADDR) {
-		db_printf("%sSO_REUSEADDR", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_KEEPALIVE) {
-		db_printf("%sSO_KEEPALIVE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_DONTROUTE) {
-		db_printf("%sSO_DONTROUTE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_BROADCAST) {
-		db_printf("%sSO_BROADCAST", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_USELOOPBACK) {
-		db_printf("%sSO_USELOOPBACK", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_LINGER) {
-		db_printf("%sSO_LINGER", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_OOBINLINE) {
-		db_printf("%sSO_OOBINLINE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_REUSEPORT) {
-		db_printf("%sSO_REUSEPORT", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_TIMESTAMP) {
-		db_printf("%sSO_TIMESTAMP", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_NOSIGPIPE) {
-		db_printf("%sSO_NOSIGPIPE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_ACCEPTFILTER) {
-		db_printf("%sSO_ACCEPTFILTER", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_BINTIME) {
-		db_printf("%sSO_BINTIME", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_NO_OFFLOAD) {
-		db_printf("%sSO_NO_OFFLOAD", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_options & SO_NO_DDP) {
-		db_printf("%sSO_NO_DDP", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG_INIT;
+
+	PRINT_FLAG(so_options, SO_DEBUG);
+	PRINT_FLAG(so_options, SO_ACCEPTCONN);
+	PRINT_FLAG(so_options, SO_REUSEADDR);
+	PRINT_FLAG(so_options, SO_KEEPALIVE);
+	PRINT_FLAG(so_options, SO_DONTROUTE);
+	PRINT_FLAG(so_options, SO_BROADCAST);
+	PRINT_FLAG(so_options, SO_USELOOPBACK);
+	PRINT_FLAG(so_options, SO_LINGER);
+	PRINT_FLAG(so_options, SO_OOBINLINE);
+	PRINT_FLAG(so_options, SO_REUSEPORT);
+	PRINT_FLAG(so_options, SO_TIMESTAMP);
+	PRINT_FLAG(so_options, SO_NOSIGPIPE);
+	PRINT_FLAG(so_options, SO_ACCEPTFILTER);
+	PRINT_FLAG(so_options, SO_BINTIME);
+	PRINT_FLAG(so_options, SO_NO_OFFLOAD);
+	PRINT_FLAG(so_options, SO_NO_DDP);
 }
 
 static void
 db_print_sostate(short so_state)
 {
-	int comma;
-
-	comma = 0;
-	if (so_state & SS_NOFDREF) {
-		db_printf("%sSS_NOFDREF", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_ISCONNECTED) {
-		db_printf("%sSS_ISCONNECTED", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_ISCONNECTING) {
-		db_printf("%sSS_ISCONNECTING", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_ISDISCONNECTING) {
-		db_printf("%sSS_ISDISCONNECTING", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_NBIO) {
-		db_printf("%sSS_NBIO", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_ASYNC) {
-		db_printf("%sSS_ASYNC", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_ISCONFIRMING) {
-		db_printf("%sSS_ISCONFIRMING", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_state & SS_PROTOREF) {
-		db_printf("%sSS_PROTOREF", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG_INIT;
+
+	PRINT_FLAG(so_state, SS_NOFDREF);
+	PRINT_FLAG(so_state, SS_ISCONNECTED);
+	PRINT_FLAG(so_state, SS_ISCONNECTING);
+	PRINT_FLAG(so_state, SS_ISDISCONNECTING);
+	PRINT_FLAG(so_state, SS_NBIO);
+	PRINT_FLAG(so_state, SS_ASYNC);
+	PRINT_FLAG(so_state, SS_ISCONFIRMING);
+	PRINT_FLAG(so_state, SS_PROTOREF);
 }
 
 static void
 db_print_soqstate(int so_qstate)
 {
-	int comma;
+	PRINT_FLAG_INIT;
 
-	comma = 0;
-	if (so_qstate & SQ_INCOMP) {
-		db_printf("%sSQ_INCOMP", comma ? ", " : "");
-		comma = 1;
-	}
-	if (so_qstate & SQ_COMP) {
-		db_printf("%sSQ_COMP", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG(so_qstate, SQ_INCOMP);
+	PRINT_FLAG(so_qstate, SQ_COMP);
 }
 
 static void
 db_print_sbstate(short sb_state)
 {
-	int comma;
+	PRINT_FLAG_INIT;
 
-	comma = 0;
-	if (sb_state & SBS_CANTSENDMORE) {
-		db_printf("%sSS_CANTSENDMORE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_state & SBS_CANTRCVMORE) {
-		db_printf("%sSS_CANTRCVMORE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_state & SBS_RCVATMARK) {
-		db_printf("%sSS_RCVATMARK", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG(sb_state, SBS_CANTSENDMORE);
+	PRINT_FLAG(sb_state, SBS_CANTRCVMORE);
+	PRINT_FLAG(sb_state, SBS_RCVATMARK);
 }
 
 static void
@@ -266,37 +180,15 @@ db_print_domain(struct domain *d, const char *domain_name, int indent)
 static void
 db_print_prflags(short pr_flags)
 {
-	int comma;
-
-	comma = 0;
-	if (pr_flags & PR_ATOMIC) {
-		db_printf("%sPR_ATOMIC", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_ADDR) {
-		db_printf("%sPR_ADDR", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_CONNREQUIRED) {
-		db_printf("%sPR_CONNREQUIRED", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_WANTRCVD) {
-		db_printf("%sPR_WANTRCVD", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_RIGHTS) {
-		db_printf("%sPR_RIGHTS", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_IMPLOPCL) {
-		db_printf("%sPR_IMPLOPCL", comma ? ", " : "");
-		comma = 1;
-	}
-	if (pr_flags & PR_LASTHDR) {
-		db_printf("%sPR_LASTHDR", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG_INIT;
+
+	PRINT_FLAG(pr_flags, PR_ATOMIC);
+	PRINT_FLAG(pr_flags, PR_ADDR);
+	PRINT_FLAG(pr_flags, PR_CONNREQUIRED);
+	PRINT_FLAG(pr_flags, PR_WANTRCVD);
+	PRINT_FLAG(pr_flags, PR_RIGHTS);
+	PRINT_FLAG(pr_flags, PR_IMPLOPCL);
+	PRINT_FLAG(pr_flags, PR_LASTHDR);
 }
 
 static void
@@ -342,41 +234,16 @@ db_print_protosw(struct protosw *pr, const char *prname, int indent)
 static void
 db_print_sbflags(short sb_flags)
 {
-	int comma;
-
-	comma = 0;
-	if (sb_flags & SB_WAIT) {
-		db_printf("%sSB_WAIT", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_SEL) {
-		db_printf("%sSB_SEL", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_ASYNC) {
-		db_printf("%sSB_ASYNC", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_UPCALL) {
-		db_printf("%sSB_UPCALL", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_NOINTR) {
-		db_printf("%sSB_NOINTR", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_AIO) {
-		db_printf("%sSB_AIO", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_KNOTE) {
-		db_printf("%sSB_KNOTE", comma ? ", " : "");
-		comma = 1;
-	}
-	if (sb_flags & SB_AUTOSIZE) {
-		db_printf("%sSB_AUTOSIZE", comma ? ", " : "");
-		comma = 1;
-	}
+	PRINT_FLAG_INIT;
+
+	PRINT_FLAG(sb_flags, SB_WAIT);
+	PRINT_FLAG(sb_flags, SB_SEL);
+	PRINT_FLAG(sb_flags, SB_ASYNC);
+	PRINT_FLAG(sb_flags, SB_UPCALL);
+	PRINT_FLAG(sb_flags, SB_NOINTR);
+	PRINT_FLAG(sb_flags, SB_AIO);
+	PRINT_FLAG(sb_flags, SB_KNOTE);
+	PRINT_FLAG(sb_flags, SB_AUTOSIZE);
 }
 
 static void
@@ -528,4 +395,8 @@ DB_SHOW_COMMAND(domain, db_show_domain)
 
 	db_print_domain(d, "domain", 0);
 }
+
+#undef PRINT_FLAG
+#undef PRINT_FLAG_INIT
+
 #endif
-- 
1.8.1.3
--- 0001-uipc-Simplify-and-correct-debug-printing-of-flags.patch ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: brueffer 
State-Changed-When: Thu Feb 27 11:00:28 CET 2014 
State-Changed-Why:  
The patch in the PR doesn't compile (latest HEAD).  The one here works, but is a bit ugly: 
https://people.freebsd.org/~brueffer/uipc_debug.c.diff 

Do you have a better suggestion? 


Responsible-Changed-From-To: freebsd-bugs->brueffer 
Responsible-Changed-By: brueffer 
Responsible-Changed-When: Thu Feb 27 11:00:28 CET 2014 
Responsible-Changed-Why:  
I'll take care of this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=176051 

From: Christian Brueffer <brueffer@FreeBSD.org>
To: Christoph Mallon <christoph.mallon@gmx.de>, freebsd-bugs@FreeBSD.org, 
 freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/176051: [kernel] [patch] uipc: Simplify and correct debug
 printing of flags.
Date: Thu, 06 Mar 2014 00:28:06 +0100

 This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
 --uTXQmgdEWMt8NaR0n4D1xk0jES7R3G4rg
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 On 3/4/14 8:29 AM, Christoph Mallon wrote:
 > On 27.02.2014 11:02, brueffer@FreeBSD.org wrote:
 >> The patch in the PR doesn't compile (latest HEAD).
 >=20
 >=20
 > "doesn't compile" is not helpful feedback.
 > Please state at least the error message.
 >=20
 
 [...]
 cc  -c -O2 -pipe -fno-strict-aliasing  -std=3Dc99 -gdwarf-2 -Wall
 -Wredundant-decls -Wnested-externs -Wstrict-prototypes
 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef
 -Wno-pointer-sign -fformat-extensions  -Wmissing-include-dirs
 -fdiagnostics-show-option  -Wno-error-tautological-compare
 -Wno-error-empty-body  -Wno-error-parentheses-equality
 -Wno-unused-function   -nostdinc  -I. -I/usr/src/sys
 -I/usr/src/sys/contrib/altq -I/usr/src/sys/contrib/libfdt -D_KERNEL
 -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mno-aes -mno-avx
 -mcmodel=3Dkernel -mno-red-zone -mno-mmx -mno-sse -msoft-float
 -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -Werror
  /usr/src/sys/kern/uipc_debug.c
 /usr/src/sys/kern/uipc_debug.c:87:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_DEBUG);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:87:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:87:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_DEBUG);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:88:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_ACCEPTCONN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:88:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:88:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_ACCEPTCONN);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:89:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_REUSEADDR);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:89:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:89:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_REUSEADDR);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:90:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_KEEPALIVE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:90:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:90:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_KEEPALIVE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:91:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_DONTROUTE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:91:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:91:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_DONTROUTE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:92:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_BROADCAST);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:92:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:92:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_BROADCAST);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:93:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_USELOOPBACK);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:93:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:93:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_USELOOPBACK);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:94:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_LINGER);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:94:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:94:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_LINGER);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:95:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_OOBINLINE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:95:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 /usr/src/sys/kern/uipc_debug.c:95:2: error: format string is not a
 string literal (potentially insecure) [-Werror,-Wformat-security]
         PRINT_FLAG(so_options, SO_OOBINLINE);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:33: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ^~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:96:2: error: adding 'int' to a string
 does not append to the string [-Werror,-Wstring-plus-int]
         PRINT_FLAG(so_options, SO_REUSEPORT);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                 ~~~~~~~~~~~^~~~~
 /usr/src/sys/kern/uipc_debug.c:96:2: note: use array indexing to silence
 this warning
 /usr/src/sys/kern/uipc_debug.c:49:44: note: expanded from macro 'PRINT_FL=
 AG'
     ((var) & (flag) ? db_printf(", " #flag + sep), (void)(sep =3D 0) :
 (void)0)
                                            ^
 fatal error: too many errors emitted, stopping now [-ferror-limit=3D]
 20 errors generated.
 *** Error code 1
 
 
 # cc -v
 FreeBSD clang version 3.4 (tags/RELEASE_34/final 197956) 20140216
 Target: x86_64-unknown-freebsd11.0
 Thread model: posix
 Selected GCC installation:
 
 
 Christian
 
 
 --uTXQmgdEWMt8NaR0n4D1xk0jES7R3G4rg
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
 
 iQJ8BAEBCgBmBQJTF7MIXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ5QzhCQjQ5MDgzNDUwNjkyOUM5Mjg2NDE3
 OEM4MzY5ODQ3RTE2NDg3AAoJEHjINphH4WSHy5YP/2uSrj+WrwxrnpP07phJfFlT
 wGOOavTUbnviAh2+QzKWRxrG3IrNUT3xo2N7XhBXtaFmriCiO/pn83mKLtEK7FvF
 au7n0Nj5iHZjUAFlVAA80isxlZMhHLzk6Hz7JJ6zAq6+rsPyuDNBBgPDA1ye6HIw
 2qHeM/GGpizoj5UStXYYwuirLlMEyDlWACZRMS9BrqXGmI2kon98vgdppEX+vaaP
 1TxElrBPN2L7uW3B0Ni6L5wfbJT/bjEHe82USY8AD2FH9qSEFquWpo3pT8iBnKz9
 sD13ZoFcrlHTzSwJW1+Ma0TBMs/AzDkUh8gMvXLLM4OkDh6PiDSTZ266A89E7nXf
 Dw9u+2k/+DdZ19ea6oTSnOt0NilJduli/XS+nkho7Z7bqTNCUbOCA9mpKES2aHdv
 +Hsr+zNo6XtUalctpOZDewpvmutML1r56NSE4FhtakbDkhJUIh8+pjL7bPBAnN4/
 XKSdlmEMT0srBiS9S492JrbBd8eSfmKXlwIeQ80QaEOv5YC+KqrCorzsFTvP/z8D
 GjWvGXoXtJma0ZAXaZW1qDShDFSrW/2NI16KwoxgB8ULsSQVYs4JxiMIsWu428nx
 CO4luEEtYU+gFgSePhXoVQNKahcMrbowYFK+mi8xql7TwijMrC6ZPBkDyQ54eeZy
 UXuKO8yibqBYYQLarFDE
 =E40n
 -----END PGP SIGNATURE-----
 
 --uTXQmgdEWMt8NaR0n4D1xk0jES7R3G4rg--

From: Christoph Mallon <christoph.mallon@gmx.de>
To: Christian Brueffer <brueffer@FreeBSD.org>, freebsd-bugs@FreeBSD.org, 
 freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/176051: [kernel] [patch] uipc: Simplify and correct debug
 printing of flags.
Date: Mon, 31 Mar 2014 09:32:13 +0200

 On 06.03.2014 00:28, Christian Brueffer wrote:
 > /usr/src/sys/kern/uipc_debug.c:87:2: error: adding 'int' to a string
 > does not append to the string [-Werror,-Wstring-plus-int]
 
 No shit, Sherlock!
 This is just clang being unhelpful.
 The code is perfectly fine.
 Who came up with this stupid warning?
 I'll provide another patch.
 
 	Christoph
>Unformatted:
