Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3581688rwb; Fri, 30 Sep 2022 05:43:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Orudxhqd99hQkheNd9qKzDeZV2ZysjG2gUccSiQison7+aGIe1lP+TbhCD9+HfEZYx1k1 X-Received: by 2002:a17:902:e749:b0:178:3980:45ad with SMTP id p9-20020a170902e74900b00178398045admr8715948plf.153.1664541830845; Fri, 30 Sep 2022 05:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664541830; cv=none; d=google.com; s=arc-20160816; b=J7KJ7x3s+zn51aJMn07CsLEaH4fn/1b6k53NpLcmAa56kze0wVPKcV9h+xluwqkJI6 266nqLR3K0FE2WPzN7R/6lKVk7QfxJdW++QZid6BLPZED1Uy6peIm1VYwCl8rM9eFLxV WIYZbQ+JgwU8EiEFeMw3DbMUMtE8ePeRXz3co8Fmk1r54neUGMrOxlkHilmPNPk8/ReF iyaZqlLtW5Oxqg8S/i+MdGT/5eE7DuL21/JjaycSbKpljoMy6olM87aNHRoWrdKEIK4L DqQjThZa+4dUzVy+/GiRydWTDZxxbrO/5E53VDmSZmwn+s+Oceo3kysKxaQzIEby+3/E dBpg== 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=3K9E1VKNQHrn5Pq9cUMtYb8GFqAtrYNZLx+gW74CPko=; b=Ehk3oelDdgXqx5oKBjUH+b3Rf3SewNbgNy/RTolNsO6uC1sUYXNfTeVR+Fgb/2UZTq SRPQWTF92XTfw9121tncqskTQaNid5DN28KkKLKdXzXvyfCHFQ8iNwbrcI9glhHwYjdA 1UVP675pSKXnnYN5s/FfQEX5iwphIaxt5BZ5cRvQ05YSuTK3cA+DY9TzhqjbTwB+Oul5 gfXKZkxUsEs/xP3KLHcIf8t7wGO7SV/Q9Q2nTRJMYdOX+zAAUx6vjiNYKY/UK93RqEFr zpcoFsn3ADSbxuIw/kJruVJWGCE8NFKMOnXvdNqWtNDd91Osf+qH0Zk8R6oerF1mu3Hb 5f2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zP4PMGO0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x14-20020a056a00188e00b0052f60f7e0a1si2653604pfh.5.2022.09.30.05.43.38; Fri, 30 Sep 2022 05:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zP4PMGO0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbiI3MZD (ORCPT + 99 others); Fri, 30 Sep 2022 08:25:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiI3MYy (ORCPT ); Fri, 30 Sep 2022 08:24:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40D1DD6D for ; Fri, 30 Sep 2022 05:24:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D1CA262311 for ; Fri, 30 Sep 2022 12:24:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE43DC433D6; Fri, 30 Sep 2022 12:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664540691; bh=gw4uy+OJSbBCFmLpGyxFPSyMbSJHYjmDGwhUaCPGUQk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zP4PMGO0PCU2Ftg77Wpemze2pFkAf3nZSRujTPgACYbgCYqKVxeyge5f2hWLivxew vBcQ/G+t/kjlSVGvyCHd+7FOt7h2ooqRrtHcuHgtQ5R5Eq9DnL8ns9UTHXYfDWlFYP stnXnFqbQYvFLJoh+OLuNF99xDci+pZLN3TfBCmc= Date: Fri, 30 Sep 2022 14:24:48 +0200 From: Greg KH To: Jules Irenge Cc: hsweeten@visionengravers.com, abbotti@mev.co.uk, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] comedi: Convert snprintf() to sysfs_emit() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 28, 2022 at 02:23:41PM +0100, Jules Irenge wrote: > Coccinnelle reports a warning > Warning: Use scnprintf or sprintf > > Adding to that, there has been a slow migration from snprintf to scnprintf. > This LWN article explains the rationale for this change > > https: //lwn.net/Articles/69419/ > ie. snprintf() returns what *would* be the resulting length, > while scnprintf() returns the actual length. None of this is needed or relevant for this change. > > However following the advice on > https://www.kernel.org/doc/html/latest/filesystems/sysfs.html > > For show(device *...) functions we should only use sysfs_emit() or sysfs_emit_at() > especially when formatting the value to be returned to user space. > > Hence here > We convert to sysfs_emit() that even does better and shorten the code > using the same rationale of scnprintf() > > Signed-off-by: Jules Irenge > --- > > v2: Replace scnprintf() with sysfs_emit() > > drivers/comedi/comedi_fops.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c > index 55a0cae04b8d..a6017fafcb2a 100644 > --- a/drivers/comedi/comedi_fops.c > +++ b/drivers/comedi/comedi_fops.c > @@ -396,7 +396,7 @@ static ssize_t max_read_buffer_kb_show(struct device *csdev, > mutex_unlock(&dev->mutex); > > comedi_dev_put(dev); > - return snprintf(buf, PAGE_SIZE, "%u\n", size); > + return sysfs_emit(buf, "%u\n", size); > } > > static ssize_t max_read_buffer_kb_store(struct device *csdev, Does not apply to my tree :( thanks, greg k-h