Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Mar 2012 23:10:33 GMT
From:      Arne Meyer <meyer.arne83@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/165699: [patch] make sbin/mca compile with clang
Message-ID:  <201203042310.q24NAXjm070856@red.freebsd.org>
Resent-Message-ID: <201203042320.q24NK8FI041353@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         165699
>Category:       bin
>Synopsis:       [patch] make sbin/mca compile with clang
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 04 23:20:08 UTC 2012
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203042310.q24NAXjm070856>