Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3328830pxb; Wed, 13 Oct 2021 03:52:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVNtxok5dL1p9UPx9mlwxGZeKkpd6e0rAR3HhLarvhz9OKC/UlJNEa7yHxIlJarxNtTxpQ X-Received: by 2002:a17:902:778a:b0:13f:672c:103a with SMTP id o10-20020a170902778a00b0013f672c103amr2943615pll.55.1634122337959; Wed, 13 Oct 2021 03:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634122337; cv=none; d=google.com; s=arc-20160816; b=lcwFRVANDCYscU+Qbl3yD4mYpq1U5SalqJ8tC/DgDBblNTKdPVclZyObZQaxGvWUlk MP7YyU0ycP1UMe748r3l27pknhg91TETPb2MR89JeVyemfPKuSy9lgpmLcSZI+WEjVE6 Z8vkWAlxOH0P9Zl//5uiok+1huwvtuOhyAyfZKf0F7M0Z6s4i1ag/mOmFopkFLG2E3Rk oaQ+t2J0s8RIIgkk5O4GY4qh5vlCkE5mnvr+U2DXf5Lbm1kNJe9L+L20THUerrTR+RaD 5FbMn0NH5slGHfjY4iwWe2GOT82C4iWPE7wt90gadQi6ATS3Lynjrx4ScFrIBaU618Wf cBRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=Pc+aE/ebEqA5ohTowjbjdlhCperTwnJXTUqIOVJUNbU=; b=c6iY25oxKi8jTAUOZK6d/ldmVjMJHOKDf0aICjYdCzhPnTfrcIMV2pdqkJrnvpcyJj YpWZS6mSCl/IKftA4YmOvS3Nyw3ajEhglzM1HiG0rz6rIPWMBd74miVO9Xw9hK45ORXs 1CuUMc0itYWQgTrnO474hrA4BHMzA6icDGRXr+t+RFlTm9joYUdj3JElq2llLilpnHCT zlloCzwtQWiy7X8i0NZsUblxB9h5vhJvwO/8KTdA5t/02+icLRVnNRtFy3ceFomrWGj5 t4LiDeRooyk2pJzhiqTqybnYSo9EpR2bNub6LZus8v6hQTKBMdn54HTEvmuHUqEAp5iB lyGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=f6Z26b0G; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u4si5164998plf.415.2021.10.13.03.52.04; Wed, 13 Oct 2021 03:52:17 -0700 (PDT) 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=@gmx.net header.s=badeba3b8450 header.b=f6Z26b0G; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbhJMKvi (ORCPT + 99 others); Wed, 13 Oct 2021 06:51:38 -0400 Received: from mout.gmx.net ([212.227.15.19]:35263 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229664AbhJMKvh (ORCPT ); Wed, 13 Oct 2021 06:51:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1634122159; bh=3y1Ax8ewSDNoGoLvir72to9z/znLvie6bI0c75IcE40=; h=X-UI-Sender-Class:Date:To:References:From:Subject:In-Reply-To; b=f6Z26b0GJPuSfXqwsu3+ZE3YwXZI4TWWjZudaAlYH2k/c4WnGIhtysaeWeh3kXn/o WafeyWMnstaLvSWr0ZeWn4NkuPVPUN6rnNK6QDUhrESVVWQd8/Yqk1gus1NCMAsLAX 3iRdB8nAGix1BR2TtJ3FXASKPPuc3Qdmcu4tYVC4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MFKKh-1mYcg33vA1-00Fmrr; Wed, 13 Oct 2021 12:49:19 +0200 Message-ID: <39a70849-3550-8757-ea0a-3d641d4137f4@gmx.com> Date: Wed, 13 Oct 2021 18:49:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.1 Content-Language: en-US To: dsterba@suse.cz, Anand Jain , Qing Wang , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <1634095717-4480-1-git-send-email-wangqing@vivo.com> <6f03e790-6f21-703f-c761-a034575f465e@oracle.com> <20211013103642.GC9286@twin.jikos.cz> From: Qu Wenruo Subject: Re: [PATCH] btrfs: replace snprintf in show functions with sysfs_emit In-Reply-To: <20211013103642.GC9286@twin.jikos.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:tlyABHuiyXrsoReSwr9sfmb6Pq9RbDFi9hceUdlTr36n5U7Afm3 8AFgw/UHCmfcaVFUARhhWse/sxxPHhdyo7e8nq+9J+cX5SZ23EWLTBQRcoQwLJlic9eFqQz eN/s6Xdd3Po9LUa96amnHd3k6cnPfls+yFWtDtnwbeY1WRzx+a0mpEPwYMlPHH5Rcc1+6hL u7gAP08q7O36GmwYL4R2g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:JpPk9/HRbQg=:tmCyRzEu8J5U5Q4QpdTvqw r3IE4fAd+LprxMynNCfvpgi3sNvgsBjjJOQuHF4swmbM2bFWHBp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X-Mailing-List: linux-kernel@vger.kernel.org On 2021/10/13 18:36, David Sterba wrote: > On Wed, Oct 13, 2021 at 03:51:33PM +0800, Anand Jain wrote: >> On 13/10/2021 11:28, Qing Wang wrote: >>> coccicheck complains about the use of snprintf() in sysfs show functio= ns. >> >> It looks like the reason is snprintf() unaware of the PAGE_SIZE >> max_limit of the buf. >> >>> Fix the following coccicheck warning: >>> fs/btrfs/sysfs.c:335:8-16: WARNING: use scnprintf or sprintf. IIRC sprintf() is less safe than snprintf(). Is the check really correct to mention sprintf()? >> >> Hm. We use snprintf() at quite a lot more places in sysfs.c and, I don'= t >> see them getting this fix. Why? > > I guess the patch is only addressing the warning for snprintf, reading > the sources would show how many more conversions could have been done of > scnprintf calls. > >>> Use sysfs_emit instead of scnprintf or sprintf makes more sense. >> >> Below commit has added it. Nice. >> >> commit 2efc459d06f1630001e3984854848a5647086232 >> Date: Wed Sep 16 13:40:38 2020 -0700 >> >> sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs out > > The conversion to the standard helper is good, but should be done > in the entire file. > Yeah, the same idea, all sysfs interface should convert to the new interface, not only the snprintf(). Thanks, Qu