Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1832661rdb; Thu, 7 Dec 2023 09:53:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdeWM5RIXjLQ720lBtyOKZnhVOka7ABfqZF6lJH44yHDCIVFMZE2EnRPDYsBIuTJoRppfZ X-Received: by 2002:a17:90b:1056:b0:286:6cc0:cacc with SMTP id gq22-20020a17090b105600b002866cc0caccmr2976529pjb.67.1701971591527; Thu, 07 Dec 2023 09:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701971591; cv=none; d=google.com; s=arc-20160816; b=JHXjrGt8+s/p55I9CUu98TxxXLkCvFt4Pbts1Zmh5lsbyjzRF2HnSE8quBD32Wqwa4 AMTZQnT2OmNtruy9UwLTIh6ZkEoqCaTffsmobm5pPbdBaO/aUtY1r6PuLdgMQOjtZFD9 sgxQ9BP45caNMBWSZG6aZI1wMUpczpD4rcBIf6S5mRhVKXfoo3fQp4dqLBZHW7T5DHXr 36KPzMPmIHjw8JdVOMu2TT687L/AI2/bOkV1nuZA3n7jmm2OJzPAZed+0AvuB48KUv0C XOm42lB3D2aYuZnPVbY/jnHiFx2rHDXm4QItvVWwO93yuxNMl6GbWKG/7zDZTYqLuexi DQyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=zG2UGPXCv4/FgbLJTXPGX3Nf8DqXr0h+L8Zc4YpOnTg=; fh=PGNeKbxRU/7mOxWyU2RVHEfkaf0hpDLWqyWQtefdcpM=; b=YOuZFsjW35udso6/p6u3s3OTA7NM+kSlmB0n+hHLSNQpdHZGtw0RlA+hMc0vqPYsCV JXcZzwCzZs+i20ElvXoCOWM7YwYQct4+AeXCZhGcyRcAqk5bXyV+wv/aaTablA4+JtJd AChqzOtiMFxJt1vzC3NM1PJ8vsOsPiv+Gx+r1REfEWS+jRTPBpjPFBxciIzAv10CsOiI i2ZRza/baS0dbM+S/r53RF3yBfNKeUa6KtXO+zFNZ/W1EqXLrDLHqrNzEGnDVk9bibbB idQfA/lWV8CwI9BirWelkHcpBkiC/Ok3cnsqsAq4ko8nC9Xi2+F/buo9lXU2Y31EQ/vX iQbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=RThyG6yn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id r6-20020a17090a560600b00286b854b672si1458931pjf.157.2023.12.07.09.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:53:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=RThyG6yn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DFF7C8083ADC; Thu, 7 Dec 2023 09:53:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443578AbjLGRwx (ORCPT + 99 others); Thu, 7 Dec 2023 12:52:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443447AbjLGRww (ORCPT ); Thu, 7 Dec 2023 12:52:52 -0500 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98BA2170C; Thu, 7 Dec 2023 09:52:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:Mime-Version:Message-Id:Cc:To:From :Date:subject:date:message-id:reply-to; bh=zG2UGPXCv4/FgbLJTXPGX3Nf8DqXr0h+L8Zc4YpOnTg=; b=RThyG6ynxjFruIcj+Fjw17JpTZ 9Xlpp4UZrDFthSmK3pDHBqY5AHfVWp12rkbHjOKkuO7YeVb47/IpVphxP8OZHbED7+45vEsnAj7b2 +z4JeO/Lbt6egcVkjiaMEkDmTdrwVuILKEq9PbcLYKM+vHdhc0KUUrY+tHqcRW29k6Hk=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:57946 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rBIYG-0007oa-0U; Thu, 07 Dec 2023 12:52:45 -0500 Date: Thu, 7 Dec 2023 12:52:43 -0500 From: Hugo Villeneuve To: kernel test robot Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, hvilleneuve@dimonoff.com, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, stable@vger.kernel.org, Andy Shevchenko Message-Id: <20231207125243.c056d5cd0f875ea6dfdfa194@hugovil.com> In-Reply-To: <202312061443.Cknef7Uq-lkp@intel.com> References: <20231130191050.3165862-2-hugo@hugovil.com> <202312061443.Cknef7Uq-lkp@intel.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_CSS autolearn=unavailable autolearn_force=no version=3.4.6 Subject: Re: [PATCH 1/7] serial: sc16is7xx: fix snprintf format specifier in sc16is7xx_regmap_name() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:53:09 -0800 (PST) On Wed, 6 Dec 2023 14:29:39 +0800 kernel test robot wrote: > Hi Hugo, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on d804987153e7bedf503f8e4ba649afe52cfd7f6d] > > url: https://github.com/intel-lab-lkp/linux/commits/Hugo-Villeneuve/serial-sc16is7xx-fix-snprintf-format-specifier-in-sc16is7xx_regmap_name/20231201-031413 > base: d804987153e7bedf503f8e4ba649afe52cfd7f6d > patch link: https://lore.kernel.org/r/20231130191050.3165862-2-hugo%40hugovil.com > patch subject: [PATCH 1/7] serial: sc16is7xx: fix snprintf format specifier in sc16is7xx_regmap_name() > config: x86_64-buildonly-randconfig-001-20231201 (https://download.01.org/0day-ci/archive/20231206/202312061443.Cknef7Uq-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312061443.Cknef7Uq-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202312061443.Cknef7Uq-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > drivers/tty/serial/sc16is7xx.c: In function 'sc16is7xx_i2c_probe': > >> drivers/tty/serial/sc16is7xx.c:1703:41: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] > 1703 | snprintf(buf, sizeof(buf), "port%u", port_id); > | ^~ > In function 'sc16is7xx_regmap_name', > inlined from 'sc16is7xx_i2c_probe' at drivers/tty/serial/sc16is7xx.c:1805:17: > drivers/tty/serial/sc16is7xx.c:1703:36: note: directive argument in the range [0, 4294967294] > 1703 | snprintf(buf, sizeof(buf), "port%u", port_id); > | ^~~~~~~~ > drivers/tty/serial/sc16is7xx.c:1703:9: note: 'snprintf' output between 6 and 15 bytes into a destination of size 6 > 1703 | snprintf(buf, sizeof(buf), "port%u", port_id); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hi, the only solution I could find is to add this line just before snprintf: BUG_ON(port_id > MAX310X_MAX_PORTS); it allows us to have the smallest buffer size possible. One other solution would be to change port_id from "unsigned int" to "u8", and increase the buffer by an additional 2 bytes to silence the warning, but then wasting 2 bytes for each channel, like so: static const char *max310x_regmap_name(u8 port_id) { static char buf[ sizeof(MAX310X_PORT_NAME_SUFFIX __stringify(UCHAR_MAX))]; I prefer solution 1, unless there is another solution that I am unaware of. Hugo. > vim +1703 drivers/tty/serial/sc16is7xx.c > > 1698 > 1699 static const char *sc16is7xx_regmap_name(unsigned int port_id) > 1700 { > 1701 static char buf[6]; > 1702 > > 1703 snprintf(buf, sizeof(buf), "port%u", port_id); > 1704 > 1705 return buf; > 1706 } > 1707 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki > -- Hugo Villeneuve