From nobody@FreeBSD.org  Fri May 18 06:05:18 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D536A106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2012 06:05:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id C059B8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2012 06:05:18 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q4I65ITV048542
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 May 2012 06:05:18 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q4I65Icc048532;
	Fri, 18 May 2012 06:05:18 GMT
	(envelope-from nobody)
Message-Id: <201205180605.q4I65Icc048532@red.freebsd.org>
Date: Fri, 18 May 2012 06:05:18 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] [libiconv] fix improper handling of variadic args with ICDEBUG
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         168095
>Category:       kern
>Synopsis:       [patch] [libiconv] fix improper handling of variadic args with ICDEBUG
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 18 06:10:06 UTC 2012
>Closed-Date:    Mon May 21 02:40:18 UTC 2012
>Last-Modified:  Sun Feb 03 22:30:31 UTC 2013
>Originator:     Garrett Cooper
>Release:        9-STABLE
>Organization:
EMC Isilon
>Environment:
FreeBSD forza.west.isilon.com 9.0-STABLE FreeBSD 9.0-STABLE #4 r235133: Mon May  7 10:31:22 PDT 2012     root@forza.isilon.com:/usr/obj/usr/src/sys/FORZA  amd64
>Description:
The ICDEBUG macro doesn't compile on iconv.c:555 because it doesn't have a proper format string to handle the variadic macro hack that's implemented in ICDEBUG(..).

The attached patch fixes that by properly handling the variadic macro with the paste (##) preprocessor operator, as noted in 1 (amongst various other places).

1. http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html
>How-To-Repeat:
make -C /sys/modules/libiconv CFLAGS+=-DICONV_DEBUG all
>Fix:


Patch attached with submission follows:

Index: sys/libkern/iconv.c
===================================================================
--- sys/libkern/iconv.c	(revision 234223)
+++ sys/libkern/iconv.c	(working copy)
@@ -537,9 +537,7 @@
 iconv_lookupcp(char **cpp, const char *s)
 {
 	if (cpp == NULL) {
-		ICDEBUG("warning a NULL list passed\n", ""); /* XXX ISO variadic								macros cannot
-								leave out the
-								variadic args */
+		ICDEBUG("warning a NULL list passed\n");
 		return ENOENT;
 	}
 	for (; *cpp; cpp++)
Index: sys/sys/iconv.h
===================================================================
--- sys/sys/iconv.h	(revision 234223)
+++ sys/sys/iconv.h	(working copy)
@@ -239,7 +239,7 @@
 int iconv_converter_handler(module_t mod, int type, void *data);
 
 #ifdef ICONV_DEBUG
-#define ICDEBUG(format, ...) printf("%s: "format, __func__ , __VA_ARGS__)
+#define ICDEBUG(format, ...) printf("%s: "format, __func__ , ## __VA_ARGS__)
 #else
 #define ICDEBUG(format, ...)
 #endif


>Release-Note:
>Audit-Trail:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168095: commit references a PR
Date: Mon, 21 May 2012 02:30:35 +0000 (UTC)

 Author: kevlo
 Date: Mon May 21 02:30:22 2012
 New Revision: 235711
 URL: http://svn.freebsd.org/changeset/base/235711
 
 Log:
   Fix improper handling of variadic args with ICDEBUG
   
   PR:	kern/168095
   Submitted by:	gcooper
 
 Modified:
   head/sys/libkern/iconv.c
   head/sys/sys/iconv.h
 
 Modified: head/sys/libkern/iconv.c
 ==============================================================================
 --- head/sys/libkern/iconv.c	Mon May 21 02:23:20 2012	(r235710)
 +++ head/sys/libkern/iconv.c	Mon May 21 02:30:22 2012	(r235711)
 @@ -549,9 +549,7 @@ int
  iconv_lookupcp(char **cpp, const char *s)
  {
  	if (cpp == NULL) {
 -		ICDEBUG("warning a NULL list passed\n", ""); /* XXX ISO variadic								macros cannot
 -								leave out the
 -								variadic args */
 +		ICDEBUG("warning a NULL list passed\n", "");
  		return ENOENT;
  	}
  	for (; *cpp; cpp++)
 
 Modified: head/sys/sys/iconv.h
 ==============================================================================
 --- head/sys/sys/iconv.h	Mon May 21 02:23:20 2012	(r235710)
 +++ head/sys/sys/iconv.h	Mon May 21 02:30:22 2012	(r235711)
 @@ -240,7 +240,7 @@ int iconv_converter_tolowerstub(int c, v
  int iconv_converter_handler(module_t mod, int type, void *data);
  
  #ifdef ICONV_DEBUG
 -#define ICDEBUG(format, ...) printf("%s: "format, __func__ , __VA_ARGS__)
 +#define ICDEBUG(format, ...) printf("%s: "format, __func__ , ## __VA_ARGS__)
  #else
  #define ICDEBUG(format, ...)
  #endif
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: kevlo 
State-Changed-When: Mon May 21 02:40:06 UTC 2012 
State-Changed-Why:  
Committed, thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168095 
>Unformatted:
