Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp78025rwb; Tue, 8 Nov 2022 22:38:51 -0800 (PST) X-Google-Smtp-Source: AMsMyM6eQ5kAlT4aU7+5bbTf7atES4BeTau0HkAeBaMawXTHH/QJ+Fzl4ADNdr0uI6EejKnuBQ7z X-Received: by 2002:a17:902:d54c:b0:186:c092:97db with SMTP id z12-20020a170902d54c00b00186c09297dbmr59499450plf.28.1667975930956; Tue, 08 Nov 2022 22:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667975930; cv=none; d=google.com; s=arc-20160816; b=ss+Qd5V9S+YBc7ULJnEjn/q22ZTLcAs0REx9yf4blc61+AM25Y7b8z3o1Az+gbi3Ks mue8ELND9B3on9wfskXqRyeM9jJL8owT/G8K+HMBcPzxudrV4HDS1Fo06lXTxmvWzTsH Y6gMJf1zk/6BUeR0Wzo0+wIi6vQuQHTz9XOjjOT0v/Pqv5gkilsBW0ZN9w4WD77r7/iM VhuSERaObwpUEilL0mSKKaLBHLg3Uur+sMUfceIw/EvXLxNAWQtlIdPucZcDglyFJc9v Cjbz6pRh59Klr1qXkH2x8vhLZA/Vzyl6lTbQ/s5c5CvQIUxwA4ct4zxLvfwC+xyw6FvH o64Q== 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=uGAskUEWYQnM+Cxo8bqottSuYnhnXQqJkfg2TiK6eo8=; b=Ci9idieCd7UdMX8DwJe990BcQYyMNqMSIEkYeqVySOZ6ldD4LPeRJLTHOsBeigH0w8 TAGtJfdW0eUK4uUx+6qtGmCGWgbC4LwE7/wfdEybjSlwfCnF2YTkzVybgdLKQnRq7A/1 FaeFo909n+DxBsz83yX4rmYjoqYBr5ydBXVkqPdJsW8Lhj7dyWEao84LRK6yutyZmoe4 FCzKji+mavyhgeZaGPIepfwX2bz5FZjk3hlwzt5hVcwvCEo1w1yl4XxrSztJELU91whh epA9mQHIx6lViuCvU5xYTM+ej0BkVjW9usYnhpXx+gyOg2qBMyx5WMAikej5vKA/nN9j 1E3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=Vjez+ZUQ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a631f47000000b0046ec2ad4a97si16843764pgm.163.2022.11.08.22.38.14; Tue, 08 Nov 2022 22:38:50 -0800 (PST) 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=fail header.i=@mailo.com header.s=mailo header.b=Vjez+ZUQ; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbiKIGF2 (ORCPT + 94 others); Wed, 9 Nov 2022 01:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiKIGF1 (ORCPT ); Wed, 9 Nov 2022 01:05:27 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7D61F2C4 for ; Tue, 8 Nov 2022 22:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667973918; bh=UpryTxk0IC1D/WMl2KTZAYMoVR3gBZrWsZdRJgHrtjs=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=Vjez+ZUQz+YVS2zskN33qFt+2hTguqOjUIzliYtsRiQjMa+X4ZLdwzpY4edNaHv2R zTbw7yVxlnyROdgByvz31jkvqYb29MODVcSYw37myKcs9w0kOb44WoDjeDNjogDAzs qCa0jxxjHE4sVOdlVL0SwTiHOZFCI07ormEsbmhg= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Wed, 9 Nov 2022 07:05:18 +0100 (CET) X-EA-Auth: 9O9s//cR3T3uVW5c+r20zFbSlAD3wPMpc1d79hUcLPbruqOtS1v938YK+F3h6BzfmWPLTG2mmS3HaBy4uoXaGvOcK6RzFNYu Date: Wed, 9 Nov 2022 11:35:12 +0530 From: Deepak R Varma To: Greg Kroah-Hartman Cc: outreachy@lists.linux.dev, Sven Van Asbroeck , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: fieldbus: convert snprintf to scnprintf 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Tue, Nov 08, 2022 at 04:13:12PM +0100, Greg Kroah-Hartman wrote: > On Wed, Nov 02, 2022 at 11:55:52PM +0530, Deepak R Varma wrote: > > It is recommended to use scnprintf instead of snprintf to accurately > > return the size of the encoded data. Following article [1] has details > > on the reason for this kernel level migration. This issue was identified > > using coccicheck. > > > > [1] https://lwn.net/Articles/69419/ > > > > Signed-off-by: Deepak R Varma > > --- > > drivers/staging/fieldbus/dev_core.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c > > index 5aab734606ea..d51f2b02d5e6 100644 > > --- a/drivers/staging/fieldbus/dev_core.c > > +++ b/drivers/staging/fieldbus/dev_core.c > > @@ -70,7 +70,7 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr, > > * card_name was provided by child driver, could potentially be long. > > * protect against buffer overrun. > > */ > > - return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name); > > + return scnprintf(buf, PAGE_SIZE, "%s\n", fb->card_name); > > No, neither of these are correct. > > Please use sysfs_emit() for sysfs show callbacks. Hello Greg, Thank you. I corrected and resubmitted the patch as suggested. Hi Julia, The device_attr_show.cocci file should have made the recommendation to use the sysfs_emit(), however, in this case it instead suggested to use scnprintf. Is it because the method name was not "show" but "xxx_show"? Thank you, ./drv > > thanks, > > greg k-h