From nobody@FreeBSD.org  Sun Mar  4 23:10:33 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 DA9671065674
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Mar 2012 23:10:33 +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 ACF4E8FC20
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Mar 2012 23:10:33 +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 q24NAXbe070858
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 4 Mar 2012 23:10:33 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q24NAXjm070856;
	Sun, 4 Mar 2012 23:10:33 GMT
	(envelope-from nobody)
Message-Id: <201203042310.q24NAXjm070856@red.freebsd.org>
Date: Sun, 4 Mar 2012 23:10:33 GMT
From: Arne Meyer <meyer.arne83@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] make sbin/mca compile with clang
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165699
>Category:       bin
>Synopsis:       [patch] make sbin/mca compile with clang
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 04 23:20:08 UTC 2012
>Closed-Date:    Thu Jun 14 06:57:28 UTC 2012
>Last-Modified:  Thu Jun 14 06:57:28 UTC 2012
>Originator:     Arne Meyer
>Release:        9-STABLE
>Organization:
>Environment:
FreeBSD partyvan 9.0-STABLE FreeBSD 9.0-STABLE #1 r232126M: Fri Feb 24 21:15:58 CET 2012     pk@partyvan:
/usr/obj/usr/src/sys/PARTYVAN  i386
>Description:
partyvan# make CC=clang
clang -O2 -pipe  -std=gnu99 -fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unus
ed-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-s
trings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wno-uninitialized -Wno-pointer-sign -c mca.c
mca.c:473:11: error: format string is not a string literal (potentially insecure)
      [-Werror,-Wformat-security]
                        err(1, hw_mca_count);
                               ^~~~~~~~~~~~
mca.c:480:11: error: format string is not a string literal (potentially insecure)
      [-Werror,-Wformat-security]
                        err(1, hw_mca_first);
                               ^~~~~~~~~~~~
mca.c:484:11: error: format string is not a string literal (potentially insecure)
      [-Werror,-Wformat-security]
                        err(1, hw_mca_last);
                               ^~~~~~~~~~~
3 errors generated.
*** Error code 1
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- mca.c.orig	2012-03-04 23:50:42.000000000 +0100
+++ mca.c	2012-03-04 23:53:11.000000000 +0100
@@ -55,10 +55,10 @@
 
 #define	HW_MCA_MAX_CPUID	255
 
-static char hw_mca_count[] = "hw.mca.count";
-static char hw_mca_first[] = "hw.mca.first";
-static char hw_mca_last[] = "hw.mca.last";
-static char hw_mca_recid[] = "hw.mca.%lu.%u";
+static const char hw_mca_count[] = "hw.mca.count";
+static const char hw_mca_first[] = "hw.mca.first";
+static const char hw_mca_last[] = "hw.mca.last";
+static const char hw_mca_recid[] = "hw.mca.%lu.%u";
 
 static char default_dumpfile[] = "/var/log/mca.log";
 
@@ -487,7 +487,7 @@
 		error = 0;
 		while (count && first <= last) {
 			do {
-				sprintf(mib, hw_mca_recid, first, cpuid);
+				sprintf(mib, hw_mca_recid, (unsigned long)first, cpuid);
 				len = 0;
 				ch = sysctlbyname(mib, NULL, &len, NULL, 0);
 				error = (ch == -1) ? errno : 0;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Mar 4 23:23:13 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165699 
State-Changed-From-To: open->analyzed 
State-Changed-By: eadler 
State-Changed-When: Tue May 15 02:32:46 UTC 2012 
State-Changed-Why:  
awaiting approval with minor modifications 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/165699: commit references a PR
Date: Thu, 31 May 2012 08:22:17 +0000 (UTC)

 Author: eadler
 Date: Thu May 31 08:22:02 2012
 New Revision: 236355
 URL: http://svn.freebsd.org/changeset/base/236355
 
 Log:
   Fix a variety of compile errors with gcc48 and clang
   
   PR:		bin/165699
   Submitted by:	Arne Meyer <meyer.arne83@gmail.com>
   Approved by:	cperciva
   MFC after:	1 week
 
 Modified:
   head/sbin/mca/Makefile
   head/sbin/mca/mca.c
 
 Modified: head/sbin/mca/Makefile
 ==============================================================================
 --- head/sbin/mca/Makefile	Thu May 31 07:44:27 2012	(r236354)
 +++ head/sbin/mca/Makefile	Thu May 31 08:22:02 2012	(r236355)
 @@ -1,6 +1,5 @@
  # $FreeBSD$
  PROG=	mca
 -WARNS?=	4
  MAN=	mca.8
  
  .include <bsd.prog.mk>
 
 Modified: head/sbin/mca/mca.c
 ==============================================================================
 --- head/sbin/mca/mca.c	Thu May 31 07:44:27 2012	(r236354)
 +++ head/sbin/mca/mca.c	Thu May 31 08:22:02 2012	(r236355)
 @@ -55,10 +55,10 @@ __FBSDID("$FreeBSD$");
  
  #define	HW_MCA_MAX_CPUID	255
  
 -static char hw_mca_count[] = "hw.mca.count";
 -static char hw_mca_first[] = "hw.mca.first";
 -static char hw_mca_last[] = "hw.mca.last";
 -static char hw_mca_recid[] = "hw.mca.%lu.%u";
 +static const char hw_mca_count[] = "hw.mca.count";
 +static const char hw_mca_first[] = "hw.mca.first";
 +static const char hw_mca_last[] = "hw.mca.last";
 +static const char hw_mca_recid[] = "hw.mca.%d.%u";
  
  static char default_dumpfile[] = "/var/log/mca.log";
  
 @@ -162,7 +162,9 @@ show_cpu(struct mca_cpu_record *cpu)
  	char var[16];
  	struct mca_cpu_mod *mod;
  	struct mca_cpu_cpuid *cpuid;
 +#ifdef notyet
  	struct mca_cpu_psi *psi;
 +#endif
  	int i, n;
  
  	printf("    <cpu>\n");
 @@ -200,8 +202,10 @@ show_cpu(struct mca_cpu_record *cpu)
  		show_value(6, var, "0x%016llx", (long long)cpuid->cpuid[i]);
  	}
  
 -	psi = (struct mca_cpu_psi*)(cpuid + 1);
 -	/* TODO: Dump PSI */
 +#ifdef notyet
 +	 psi = (struct mca_cpu_psi*)(cpuid + 1);
 +#endif
 +	 /* TODO: Dump PSI */
  
  	printf("    </cpu>\n");
  }
 _______________________________________________
 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: analyzed->patched 
State-Changed-By: eadler 
State-Changed-When: Fri Jun 1 07:03:17 UTC 2012 
State-Changed-Why:  
committed in r236355 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/165699: commit references a PR
Date: Thu, 14 Jun 2012 06:27:13 +0000 (UTC)

 Author: eadler
 Date: Thu Jun 14 06:26:58 2012
 New Revision: 237047
 URL: http://svn.freebsd.org/changeset/base/237047
 
 Log:
   MFC r236355:
   	Fix a variety of compile errors with gcc48 and clang
   
   PR:		bin/165699
   Approved by:	cperciva (implicit)
 
 Modified:
   stable/9/sbin/mca/Makefile
   stable/9/sbin/mca/mca.c
 Directory Properties:
   stable/9/sbin/mca/   (props changed)
 
 Modified: stable/9/sbin/mca/Makefile
 ==============================================================================
 --- stable/9/sbin/mca/Makefile	Thu Jun 14 04:24:13 2012	(r237046)
 +++ stable/9/sbin/mca/Makefile	Thu Jun 14 06:26:58 2012	(r237047)
 @@ -1,6 +1,5 @@
  # $FreeBSD$
  PROG=	mca
 -WARNS?=	4
  MAN=	mca.8
  
  .include <bsd.prog.mk>
 
 Modified: stable/9/sbin/mca/mca.c
 ==============================================================================
 --- stable/9/sbin/mca/mca.c	Thu Jun 14 04:24:13 2012	(r237046)
 +++ stable/9/sbin/mca/mca.c	Thu Jun 14 06:26:58 2012	(r237047)
 @@ -55,10 +55,10 @@ __FBSDID("$FreeBSD$");
  
  #define	HW_MCA_MAX_CPUID	255
  
 -static char hw_mca_count[] = "hw.mca.count";
 -static char hw_mca_first[] = "hw.mca.first";
 -static char hw_mca_last[] = "hw.mca.last";
 -static char hw_mca_recid[] = "hw.mca.%lu.%u";
 +static const char hw_mca_count[] = "hw.mca.count";
 +static const char hw_mca_first[] = "hw.mca.first";
 +static const char hw_mca_last[] = "hw.mca.last";
 +static const char hw_mca_recid[] = "hw.mca.%d.%u";
  
  static char default_dumpfile[] = "/var/log/mca.log";
  
 @@ -162,7 +162,9 @@ show_cpu(struct mca_cpu_record *cpu)
  	char var[16];
  	struct mca_cpu_mod *mod;
  	struct mca_cpu_cpuid *cpuid;
 +#ifdef notyet
  	struct mca_cpu_psi *psi;
 +#endif
  	int i, n;
  
  	printf("    <cpu>\n");
 @@ -200,8 +202,10 @@ show_cpu(struct mca_cpu_record *cpu)
  		show_value(6, var, "0x%016llx", (long long)cpuid->cpuid[i]);
  	}
  
 -	psi = (struct mca_cpu_psi*)(cpuid + 1);
 -	/* TODO: Dump PSI */
 +#ifdef notyet
 +	 psi = (struct mca_cpu_psi*)(cpuid + 1);
 +#endif
 +	 /* TODO: Dump PSI */
  
  	printf("    </cpu>\n");
  }
 _______________________________________________
 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: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Thu Jun 14 06:57:28 UTC 2012 
State-Changed-Why:  
Committed. Thanks! 

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