From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751814AbdGZQln (ORCPT ); Wed, 26 Jul 2017 12:41:43 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:49592 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbdGZQll (ORCPT ); Wed, 26 Jul 2017 12:41:41 -0400 Date: Wed, 26 Jul 2017 09:41:29 -0700 (PDT) Message-Id: <20170726.094129.1536229682167646914.davem@davemloft.net> To: arnd@arndb.de Cc: jreuter@yaina.de, dhowells@redhat.com, linux-hams@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hamradio: dmascc: avoid -Wformat-overflow warning From: David Miller In-Reply-To: <20170726075548.2736340-1-arnd@arndb.de> References: <20170726075548.2736340-1-arnd@arndb.de> X-Mailer: Mew version 6.7 on Emacs 25.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 26 Jul 2017 09:41:41 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann Date: Wed, 26 Jul 2017 09:55:33 +0200 > gcc warns that the device name might overflow: > > drivers/net/hamradio/dmascc.c: In function 'dmascc_init': > drivers/net/hamradio/dmascc.c:584:22: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=] > sprintf(dev->name, "dmascc%i", 2 * n + i); > drivers/net/hamradio/dmascc.c:584:3: note: 'sprintf' output between 8 and 17 bytes into a destination of size 16 > sprintf(dev->name, "dmascc%i", 2 * n + i); > > From the static data in this file, I can tell that the index is > strictly limited to 16, so it won't overflow. This simply changes > the sprintf() to snprintf(), which is a good idea in general, > and shuts up this warning. > > Signed-off-by: Arnd Bergmann Applied to net-next.