Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4886109rdb; Tue, 12 Dec 2023 12:03:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZLJMcnHF6rxLw8jgxO8Q1ILMoK6lEwDCyAYHOyjuoXI+Ghp9nEx0LEINJmy1afT7p2BhA X-Received: by 2002:a05:6a00:1ac7:b0:6cb:bb92:1ce6 with SMTP id f7-20020a056a001ac700b006cbbb921ce6mr7290044pfv.18.1702411411234; Tue, 12 Dec 2023 12:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702411411; cv=none; d=google.com; s=arc-20160816; b=vnWi9Sb7JG7ug2KJUammVLPWUX++gnPiRQWNsae2Rv2HbaIx250X4SJ0E0CFYoOOEj u3P+jHHq2rhJRxmEp6k1wxGUObKPUtsFkceo7pDzZsawo8gZRDPjZvoHb1OhBpcF6jed cDN7qjNeP59sHpG15RA1rsb6d+NTx3WM1L8lu1AvX1E6+WXTV6WzSEBABO8wdRHcMbyN g1w8TqVn4Lrq3hefgvi3s5Y3EDFW4TIp/rW0KnOYR93E3sl8yJAv/LDlOOseZ0cVClgG kWCrXRc6dwYM8Wat5fLRopFwBs6ZmuLo6jsb8/U+CORXDyLDlAyoFA3zVTsbmAARNuzx LHiw== 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=GU5bD/tkNbwYE01vFKqUORHlQtxGJUzogaJ4KX5B+SE=; fh=n2mRqeeEb99dZEsqi15f6oMogcvKqzfgsR/E5bxY94I=; b=InzwxzqLqAXpngi3bD2oDlUxu+MJ12B5eZLY9gbPaVArjIzkr8gIcNifkI/GrnQ8qs 9g22W3SUvlFPXnC0YFrHzWe2lMByYFKDORPsWOua+zHoXNCmn45ZdkVVrlu5wWK6CgcO cG7a6rbZVCNNN7ub4i25wWFEZdw44G1TWrm9whmaUaHa7xMvHvsryZJL2scok9F+99EH VYn45aXIXK1mmEcm24aSdGadg2mDvmhAZ62Gv3wjMtQZI5oWGIeMVCRQ1hOicnS/8hpp 7fOmiojUQtL+5K97LfyLt9RmHmggMZ8xtTpr1fZS0Bh+eYwlVWfTPWaM4hQSxTq6wMUr Aw7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="VAN/d/JU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k24-20020a6568d8000000b005c66616240bsi8281522pgt.567.2023.12.12.12.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 12:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b="VAN/d/JU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 9094C80AD97C; Tue, 12 Dec 2023 12:03:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230376AbjLLUDM (ORCPT + 99 others); Tue, 12 Dec 2023 15:03:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjLLUDL (ORCPT ); Tue, 12 Dec 2023 15:03:11 -0500 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 982B38E; Tue, 12 Dec 2023 12:03:16 -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=GU5bD/tkNbwYE01vFKqUORHlQtxGJUzogaJ4KX5B+SE=; b=VAN/d/JUx6n8DA7SJeL3AgkgOn cSxx9y9yZlUFXcC3B6FH4I8KAzxipMdU68Cr7JHARKBZAHpbhqHo8DjQXD1j5HUtWNXuRw8H/xlkF j/y+wCxPoLkCNdG5pVGkTNV9YrfvE6ybnNiQGaz2Esrt+XgRIquyvu58/84CEV14giuU=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:50180 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1rD8y6-0003S3-F0; Tue, 12 Dec 2023 15:03:03 -0500 Date: Tue, 12 Dec 2023 15:03:02 -0500 From: Hugo Villeneuve To: Andy Shevchenko Cc: kernel test robot , 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 Message-Id: <20231212150302.a9ec5d085a4ba65e89ca41af@hugovil.com> In-Reply-To: References: <20231130191050.3165862-2-hugo@hugovil.com> <202312061443.Cknef7Uq-lkp@intel.com> <20231207125243.c056d5cd0f875ea6dfdfa194@hugovil.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=UTF-8 Content-Transfer-Encoding: 8bit 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 lipwig.vger.email X-Spam-Level: X-Spam-Status: No, score=-3.4 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 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 (lipwig.vger.email [0.0.0.0]); Tue, 12 Dec 2023 12:03:27 -0800 (PST) On Thu, 7 Dec 2023 20:24:45 +0200 Andy Shevchenko wrote: > On Thu, Dec 7, 2023 at 7:52 PM Hugo Villeneuve wrote: > > On Wed, 6 Dec 2023 14:29:39 +0800 > > kernel test robot wrote: > > ... > > > > 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: > > I didn't get this. It's a buffer that is rewritten on each port (why > is it even static?). Just make sure it's enough for any given number > and drop the static. > > ... > > While at it, can you look at the following items to improve? > - sc16is7xx_alloc_line() can be updated to use IDA framework > - move return xxx; to the default cases in a few functions > - if (div > 0xffff) { --> if (div >= BIT(16)) { as it better shows why > the limit is that (we have only 16 bits for the divider) > - do {} while (0) in the sc16is7xx_port_irq, WTH?! > - while (1) { -- do { } while (keep_polling); in sc16is7xx_irq() > - use in_range() in sc16is7xx_setup_mctrl_ports() ? (maybe not, dunno) > - for (i--; i >= 0; i--) { --> while (i--) { > - use spi_get_device_match_data() and i2c_get_match_data() > - 15000000 --> 15 * HZ_PER_MHZ ? > - dropping MODULE_ALIAS (and fix the ID tables, _if_ needed) > - split the code to the core / main + SPI + I2C glue drivers > > * These just come on the first glance at the code, perhaps there is > more room to improve. Hi Andy, just to let you know that I have implemented almost all of the fixes / improvements. I will submit them once V2 of this current series lands in Greg's next tree. However, for sc16is7xx_alloc_line(), I looked at using the IDA framework but it doesn't seem possible because there is no IDA function to search if a bit is set, which is a needed functionality. Hugo Villeneuve