Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3319234pxb; Wed, 13 Oct 2021 03:39:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDZoLeK+ocG6SPz1CNAIdgpeAjuizgyR8E3GpIc6pxe7NsKXAKTgGt/P/i5hl9eNgBZT8u X-Received: by 2002:a17:907:75e1:: with SMTP id jz1mr40828101ejc.439.1634121577295; Wed, 13 Oct 2021 03:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634121577; cv=none; d=google.com; s=arc-20160816; b=oHji90tzQpJVmdyqQiSU8sWWfODY1k0tz40cnt6ewlCvpX1MzBmDyeQu6n5DkXGHTB 0if0VvM4OK3Ug42i86Oxs6/3XRleE/TTDZx074c4kv04GTf3qx6n4JjVoSt/ChPteuql VhglVatYDMX2c9/EZ0AuRqDlKhfjXtkRrwJ9cmQxEABJhHuMYc0HrBhfHbMdoAt/kdLG uantDv0Cj8Hug73wjbOIF94UMetyqIUNUthZmPT+5wnei5HNgV8xfhLJKbO023Z4JAR7 XpQiAMsioZkZZqbQwRCwRmGUIMoWGpa4WBsIxRTa7oUH0wguy0Oi3e3HZOAGrtxumWhb farg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=pKSluFKkBVAA18SsOSV/5ZcwBta2nEJU0AbYjAs4tzY=; b=Qnvykz48QYCZv2o7LYPDircssFC4u8BoSHxHYIoddrcV1TCdTzzsP9qD0fWw/JUVxV Nz6r8CtpuSd2++CR6otaxzj+OpYMXN8wviDwchpUZNEhUPZuV4tzm2qCQYDoh3CPsPxQ gXPrCYzCv8jdpFZtfmaENU9f9vjVLJKCZVh241jt1SC6GTQx5Kwi/DcOUIDgDvWsFZar YvNcAJm4nT/qtIgDbs0G18V35+du00RysAHssSSLlsXibnQzG2r15eBDxz14GoS66P4y 2Q3ak/fp1M91zFsM0uc/WvSod1FivNlaZyWRSA0b2LHRBWNvJnEy7PFpKgIyLEXi4FPt MaWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=rdlnNv68; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kx1si20390658ejc.629.2021.10.13.03.39.10; Wed, 13 Oct 2021 03:39:37 -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=@suse.cz header.s=susede2_rsa header.b=rdlnNv68; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbhJMKjQ (ORCPT + 99 others); Wed, 13 Oct 2021 06:39:16 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:32956 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbhJMKjP (ORCPT ); Wed, 13 Oct 2021 06:39:15 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4C56C201D9; Wed, 13 Oct 2021 10:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1634121427; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pKSluFKkBVAA18SsOSV/5ZcwBta2nEJU0AbYjAs4tzY=; b=rdlnNv68JbUC/Zvmr8dCrT5cdmSpFH4VFGJ70jtcmFgv8Td5dHpC6ZP5yDqFFi2VIK/4C/ jSOrPwTCnGuy5bO9rodO2Fl8LcC+4rEYdBYptjQbMFo8dr6dLbHc6TjrMyBjVI2m9QEvf4 Iu78F7X+ZH85yb9o+VYwQcVtVSUDr/M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1634121427; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pKSluFKkBVAA18SsOSV/5ZcwBta2nEJU0AbYjAs4tzY=; b=D2JcCHU8MiUK2y+4Z7VzWk8qoMCc6NOkhBZGmhPuo3N7NT9dSFr9xd1/k4uOH9To8xIKzX cifviSva3MlGf6CA== Received: from ds.suse.cz (ds.suse.cz [10.100.12.205]) by relay2.suse.de (Postfix) with ESMTP id 1139AA3B89; Wed, 13 Oct 2021 10:37:07 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id F4050DA7A3; Wed, 13 Oct 2021 12:36:42 +0200 (CEST) Date: Wed, 13 Oct 2021 12:36:42 +0200 From: David Sterba To: Anand Jain Cc: Qing Wang , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] btrfs: replace snprintf in show functions with sysfs_emit Message-ID: <20211013103642.GC9286@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f03e790-6f21-703f-c761-a034575f465e@oracle.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 functions. > > 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. > > 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.