Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6193936pxb; Mon, 8 Nov 2021 04:49:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3LHwDVHdZMsrbsB5dQmIOiipLi/M+iosRiYFyEoDEgWdTPphMy14YCETGYcTmwCbR9suv X-Received: by 2002:a17:906:2a5a:: with SMTP id k26mr51636346eje.135.1636375748632; Mon, 08 Nov 2021 04:49:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636375748; cv=none; d=google.com; s=arc-20160816; b=UVFQqpmkNLjg+OBO1KH18VVOzcpQgFRhNVgnFMHYVnxHcvrTsPwSUxWGKrxrCaeAgA olJonj5Dod9wGoU0RKstRmKFHVUvia22qqhYTNx4TJg3q9ysB/AnbV2iNFoUkZ5qiHm0 MiosRfpPkROz+arafSIYH9ZpfjiBbngJmVc9ERkhkKKmYPUxeTo+diW8No2OCkABVFM+ GaaMRvssbyI0qPSbBUlELzZX/XOdFMbDNsbg8LujGgY1yb0mRdpusYp42XBNsuhNri42 73Zz03R9gdeePBPblbDoAjR29iB3VZP7QTMBEUk0uKOqsh+bRddqfTL8MWHU+f2zlyId u/rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ikCYYVggzULjZnDtznAo0uK/NrDJidnKRdpKZ/x14Tk=; b=fiQgwIqPqf/7Th2+W9GuvLdcx57lENyPJ1iXfBZBsGFL9gEHflAZerHtt6tUuL3cIk fp9PXenjsdFENC5VOxBd1xcTnwj2Bwlyu/OQdatWbEFOfi6jLoXQUhU5hu5Si2v/w4AK dC8WDhExanLfla4DJUptLxI1HrLVZtT8xB97LoMZJSspowV9vGDjRKNAoetiEQXGPpq0 JyOVF3Z4E4kG+ApHRBPtzXnXaqCKJ03aKBBF4yuitg/cI0dnWc5P45IUVpzDDPsC9Tl8 Om0gukm0rKabRY2mP0I81nl3PJTlsMADZjxp/O2q05HAq3ZzVpkgVhvrl1C4yamAzuL0 RVZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AokKpJV5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id js20si11304279ejc.314.2021.11.08.04.48.45; Mon, 08 Nov 2021 04:49:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AokKpJV5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238491AbhKHJ5S (ORCPT + 99 others); Mon, 8 Nov 2021 04:57:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:38036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238471AbhKHJ5C (ORCPT ); Mon, 8 Nov 2021 04:57:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 10C1561039; Mon, 8 Nov 2021 09:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636365258; bh=L2Ix2vEwlgwUCz4M38Df7/lObXnBdKVo3WLE/p151LY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AokKpJV59zKKiz9/RDeuoLzi8V5vgjhyZaiMLQJneZXIONGLg/WAMWFtu4PJY0kvJ VFb4T8C9GwBuw8YjTPogpJ3ijzjDPoDMq3IxscLGgsTxYmzI+ph2QSSQRifKPJXVVu bC14ZYYlYRlWczWA0FjGzFYPC/YEjnayif8Hhh/BaH5nHVOt/cATu9+E2BUxB+uQQL qEWBqGG3IFIn6xaiAh/v7ru0EU9rzIwdH3ZHXXMBRf5S21isYOtUswcttapGHAwelY L5I1MXOug/9xU66405oa5HGqWaXY6lmOLsTna6g+U39Z8/RduWSB59I05/qKhp4v9I GZQaPf3y81E4A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1mk1Lz-0003ai-7l; Mon, 08 Nov 2021 10:54:15 +0100 Date: Mon, 8 Nov 2021 10:54:15 +0100 From: Johan Hovold To: cgel.zte@gmail.com Cc: andrew@aj.id.au, fancer.lancer@gmail.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, joe@perches.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, macro@orcam.me.uk, pali@kernel.org, yao.jing2@zte.com.cn, zealci@zte.com.cn Subject: Re: [PATCH v3] serial: 8250: replace snprintf in show functions with sysfs_emit Message-ID: References: <20211104114754.30983-1-yao.jing2@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211104114754.30983-1-yao.jing2@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 04, 2021 at 11:47:54AM +0000, cgel.zte@gmail.com wrote: > From: Jing Yao > > coccicheck complains about the use of snprintf() in sysfs show > functions: > WARNING use scnprintf or sprintf > > Use sysfs_emit instead of scnprintf or sprintf makes more sense. > > Reported-by: Zeal Robot > Signed-off-by: Jing Yao > --- > > Changes since v1 & v2: > - Remove excess and wrong parameter 'PAGE_SIZE' in sysfs_emit function. > - Revise the wrong patch Subject. Looks like there are a few more cases in drivers/tty/serial/8250/8250_aspeed_vuart.c which you could convert in a follow up patch. > drivers/tty/serial/8250/8250_port.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c > index 5775cbff8f6e..3d58f383152e 100644 > --- a/drivers/tty/serial/8250/8250_port.c > +++ b/drivers/tty/serial/8250/8250_port.c > @@ -3099,7 +3099,7 @@ static ssize_t rx_trig_bytes_show(struct device *dev, > if (rxtrig_bytes < 0) > return rxtrig_bytes; > > - return snprintf(buf, PAGE_SIZE, "%d\n", rxtrig_bytes); > + return sysfs_emit(buf, "%d\n", rxtrig_bytes); > } > > static int do_set_rxtrig(struct tty_port *port, unsigned char bytes) This one looks good as is now: Reviewed-by: Johan Hovold Johan