Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp481105rwb; Mon, 26 Sep 2022 23:28:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65hzMcW3o1l4sksH4jpRBuJ7QJWlDvBukvQlpMA75eEFxW+MvvURRDg4+DF5BBp80LZ9Td X-Received: by 2002:a17:907:3f99:b0:782:4605:530e with SMTP id hr25-20020a1709073f9900b007824605530emr22025384ejc.108.1664260115367; Mon, 26 Sep 2022 23:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664260115; cv=none; d=google.com; s=arc-20160816; b=S1TbIPNk9Sb8MIaurMtioEgERKmG7VwZIJ7Oou6yH0IYxQneAbP+I6lDW7O9ogNGob Adi2j0LAARzl1jf28V05rkC31EmbVP65yPeD32DY68dlQoCDvd7ZLnhuVwWeA0GoUiKG XkZ4hcudCMu0Vd4K2jDT+yFuRiYzdg1tI7ymnNfDSPujtpX9eZykkppFaDqd+l6lloVm 4CAxuSrFtEJOXAxc2+0UdPNdTaue+HPTQahalrfXl0+AwyL7VW4H9E1chQ63pJ74QcKN R/cU9qOW4B7AUbQsvyhMYe8lmfQky+fQ9KcMNzh5COCSaB4gdEyPaau+aehpMYiUqQKB M/8A== 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=3UKZ+meNKY+6Vbw+e0QA1YdA7r0vXgWVuFyT1DgXdPc=; b=itMpJy9pAOh2brYojsMZEegBjUAl5sitUlsSihcdg6ujgyirhGxpSHA0Q1hhTJxxvb AaV/U91hngA/GlcgRrnnLZDgDOmm1z17cRFX/Gbpx5n7L9r+RUEuck48ZPngosMbZoQM 3g+Ru6a0OoO18JB2Q5WvkwReZT9GGa1Faot6UI252Huyhfqi73ys8lVfG4KcS0u8JQx+ qM3sqJY+dNh+oMz0Xy2jP5ilhNF8baWPxIXiK517v/cK33N/X+xuSassD7W/kaDAa06o u5mxb8x25NKiT3LyvOawA7l/A1bjJgWI+bvHnPBjmUCJuoINb2oFsi45Khci6deTsViY Pzdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="uR1U/Uye"; 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 b2-20020a17090630c200b007828c5466aesi369533ejb.168.2022.09.26.23.28.07; Mon, 26 Sep 2022 23:28:35 -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="uR1U/Uye"; 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 S229751AbiI0GG2 (ORCPT + 99 others); Tue, 27 Sep 2022 02:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbiI0GG1 (ORCPT ); Tue, 27 Sep 2022 02:06:27 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F84A59BC for ; Mon, 26 Sep 2022 23:06:25 -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 ams.source.kernel.org (Postfix) with ESMTPS id DC116B81992 for ; Tue, 27 Sep 2022 06:06:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2B9BC433D6; Tue, 27 Sep 2022 06:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664258782; bh=ELNhhCi+S5ZqZBiReMIGnz1u6k1WzveV05AquK4V1+8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uR1U/UyeXKZJ+AHBMQ+Bo5NnTdVRBKl8zqiteJ+kUZLmiGYaqK+ez9vr1POdJBj4U 8ss5ugOXkdibUQgT4vnsW+AtxT9wWNTNN5yCOUGTnKEqvgcsTWpEPTy9PuTUuw/DpE RV6WoNHgA3A+b65zzjRaXNHAmMeLzKsIwxVOr/Fo= Date: Tue, 27 Sep 2022 08:06:55 +0200 From: Greg KH To: Jules Irenge Cc: abbotti@mev.co.uk, hsweeten@visionengravers.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/7] comedi: 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=-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 Mon, Sep 26, 2022 at 07:37:37PM +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. > > Signed-off-by: Jules Irenge > --- > drivers/comedi/comedi_fops.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c > index 55a0cae04b8d..e8a0142d5894 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 scnprintf(buf, PAGE_SIZE, "%u\n", size); Ick, no, you should use sysfs_emit() if you really want to change these functions to "do the right thing". thanks, greg k-h