From patchwork Fri Jul 14 12:06:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 107781 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp887423obm; Fri, 14 Jul 2017 05:09:21 -0700 (PDT) X-Received: by 10.98.110.65 with SMTP id j62mr4882566pfc.115.1500034160950; Fri, 14 Jul 2017 05:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500034160; cv=none; d=google.com; s=arc-20160816; b=vxMKo2BLM9tyGOLQ61CGN2mPdCec9sQZIh5ROTRvkCiSP49ZOfctcDek+960aY9Nd0 DW1NGvC6fLUbtq9gjpG32Di3hxY7KLdLEUh+/QUKJV+qdoIta54i/rbbo1mFoeUyMCbs K2hkdJMPoKGZAG8GZQd0dhD45STzxBL1XW1ICLkYfHYkCG0TSne9WghBiFDSAl+Rz22r oM8jtJ0d4Dz7iF+j+tPCUqlVQAM4/Qtt5bEwrC6oS8mbWCtndujLqXZEdxlNG9QYEVrs J/Rbn4gGXk+7KCcyT0TaLb2cXsxP7WoB76174XRzU3WNw7eYPT7D40jT1nkymtq0emGE TtOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=262vGeQ9WJhAO65yl3yKZBkTYBmDYGaWPyy5MXiW1W0=; b=S5QTWOG7he4M7y3HqonDtqWHS/HdBuIqVWyz7GyGONL0MKs62Ke1K7omB7j/wfdjqk OGj3IX4ltnwDYlOL6LchQcwZcSPfN0WxdyxV1B+xKYtptjitjZBnGsTzoyEWX9D6QGLg zUrYLnZiLrZxIIx4P22xtLbUjME/XJT72bEnHROBXyS8ZKvxVHQ8ARHxoqXoC7TqKkDX Am5O9rtOdvqc45IySv1ScNsVK27VUzyZUSduLXx3DTkFs0jgumQepZ1iiWEnbmOfJHsq 75sgM2jRiTqt1wCYeoV4tAkxWx1ZY+dkFQOzm5jDdIQJFeDuA6g9FzlaZ6n87JnNA0H6 gWjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v13si6220282pfl.72.2017.07.14.05.09.20; Fri, 14 Jul 2017 05:09:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932173AbdGNMJG (ORCPT + 25 others); Fri, 14 Jul 2017 08:09:06 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:65474 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932149AbdGNMJD (ORCPT ); Fri, 14 Jul 2017 08:09:03 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MeSpb-1dIZfD3xIl-00QB4q; Fri, 14 Jul 2017 14:07:53 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Kashyap Desai , Sumit Saxena , Shivasharan S , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Greg Kroah-Hartman , Linus Torvalds , Guenter Roeck , akpm@linux-foundation.org, netdev@vger.kernel.org, "David S . Miller" , linux-scsi@vger.kernel.org, x86@kernel.org, Arnd Bergmann , megaraidlinux.pdl@broadcom.com Subject: [PATCH 02/22] scsi: megaraid: fix format-overflow warning Date: Fri, 14 Jul 2017 14:06:54 +0200 Message-Id: <20170714120720.906842-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170714120720.906842-1-arnd@arndb.de> References: <20170714120720.906842-1-arnd@arndb.de> X-Provags-ID: V03:K0:Nb/jSZEPUrrWrTuddNu5j02hMmleDrl2lRs7UNncR+y5EXQZ6iM 4Ypfc2vcETd6SMqN4z01Gc3hWMi/V+9dK0tVD7iARL24Gp0V3vtUFO+cFUi3IBa18quLroD 6iQd+Gi/bk42hgmyPmzbBCRk5wKoJ7LhKXhpQXvsY/CwJcFMOaHlCMmGnaOfGgGTBcCVGRn 2vYWzoNAHYxYmR/5e86ZA== X-UI-Out-Filterresults: notjunk:1; V01:K0:9Q7FjPlab+8=:5Yc5hFKcRdDMMdv3StKDaK gBqFvJZerPD+WbgLt4dyZUCI/GQTJzm2tbmVd2lygNT+4daPutdtbJnmRmNmzgz+kV73Qcevz 4sZk9JgAwugVVJpiIekMAUdPgW2nwifeuv3tceCB+PgPqGguQP7/qWSTkrbCUDuIeWJ9Ldovg Z2Scvx/2hpXJFgKXSatVJCuGwd4HofZWPOahfTNYp9FKcJp3z+AzPr5m88W7qayUToJvBvH1Z 12P/0hdz3Q1Iwf9W2FnPhOT4t+er2tiXTjkpkxrmw35GeUt9VY079rnrZTDBbhHtgV11wQDcl 7GrrDqALWpEUdBYqgMUJrgK6SjiYcwA/+BzkmokzCh54UBOr4Ee+jIBFKnrQiuSfhFpAmNuft xL8EVfYNL73+yFqgfbLJ5prF00+6rNxYO5fk1OKiusDAbXcWj2UIcBGzzgH2Vkup85b4CP4uj b/ndBtDA5xeAl9YGr9qOduAWWr1w0elWBqK4gJdTcuDJdMlb/PZCfc25JuM5ycH4uTaL/ZARf sLNASif5FNMe7GadHTLkZusDZ8GxeRcrkK68mvVTIUfubNnYaIyi7cj9KyMMExGkCa1611xdh QJ77PdYntdZN33w1OOlArMFx1zhi47/gCc+ts0nY3pGoW4P2/AshNXDQRp/azA2Q7OFplcadG /zR+Q+9IigsWMuLSAYcCIxGNGoj7WVHWwqCcS+ioJc1qg6aLTusYmrxKzNyGieyJ38Y3Tof66 VdV3JC+7g1yfeTivrScElL3SOLj6QJHj/iihEA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc-7 complains that the firmware version strings might overflow for some values: drivers/scsi/megaraid.c: In function 'megaraid_probe_one': drivers/scsi/megaraid.c:314:33: error: '%d' directive writing between 1 and 2 bytes into a region of size between 1 and 2 [-Werror=format-overflow=] drivers/scsi/megaraid.c:314:33: note: directive argument in the range [0, 15] drivers/scsi/megaraid.c:314:3: note: 'sprintf' output between 7 and 9 bytes into a destination of size 7 drivers/scsi/megaraid.c:320:35: error: '%d' directive writing between 1 and 2 bytes into a region of size between 1 and 2 [-Werror=format-overflow=] drivers/scsi/megaraid.c:320:35: note: directive argument in the range [0, 15] drivers/scsi/megaraid.c:320:3: note: 'sprintf' output between 7 and 9 bytes into a destination of size 7 This makes the code use a truncating snprintf() instead, which shuts up that warning. Signed-off-by: Arnd Bergmann --- drivers/scsi/megaraid.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.9.0 diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 3c63c292cb92..7195cff51d4c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -311,13 +311,15 @@ mega_query_adapter(adapter_t *adapter) right 8 bits making them zero. This 0 value was hardcoded to fix sparse warnings. */ if (adapter->product_info.subsysvid == PCI_VENDOR_ID_HP) { - sprintf (adapter->fw_version, "%c%d%d.%d%d", + snprintf(adapter->fw_version, sizeof(adapter->fw_version), + "%c%d%d.%d%d", adapter->product_info.fw_version[2], 0, adapter->product_info.fw_version[1] & 0x0f, 0, adapter->product_info.fw_version[0] & 0x0f); - sprintf (adapter->bios_version, "%c%d%d.%d%d", + snprintf(adapter->bios_version, sizeof(adapter->fw_version), + "%c%d%d.%d%d", adapter->product_info.bios_version[2], 0, adapter->product_info.bios_version[1] & 0x0f,