Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp574854rwb; Wed, 28 Sep 2022 06:34:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5RtT7hlbU4pvV7XQjJjFJCrTAzSqEdR3igcXFnPwi/OFy2hVUj23VmOw6zgLdfeMG22wIs X-Received: by 2002:a17:902:9a8b:b0:17a:455:d967 with SMTP id w11-20020a1709029a8b00b0017a0455d967mr2367043plp.52.1664372099642; Wed, 28 Sep 2022 06:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664372099; cv=none; d=google.com; s=arc-20160816; b=h337ShA/tdcXbj5FFU4/Gm1CNXjo0ePHufHahZ+shMejszR7NUJhOh0J/dxeZ5D1MU hmRMI/s28SCSUkTam0+vETGlfK9/UBCaxP+gs5/AMOc96ofUkLwoAGmYRKZIK/XcVjz9 xI9RhSy4GJgkWUOf6AxhRpvI4o+tFwSql7rKIS3FhwdBJEzGpFsQ3mWvpcKkCsBznvU6 ClK4GpBopNvecAxxRnN7Jwd4K86B99HvR7BEQWJL2LYoKO/kwBvQUyM+w1sT7COdpyhh RnyTU5e1Lj2EgQ+g5NDlTDaVmHa/QWhkJyJJLaoQsvHoM2aexSZdYEQDWD1JvGtsE7// ZYEg== 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=DnC6S+K0/VbM17qCQCLucty5V6KtRHnqqwh3CWVJLG4=; b=bv4GP2XlqewH45IL2UvJu9F41NlPtOmAndW8ip9Yx4k1WD2+SopErK8Dww4Z6uglY6 e2k1izXB2Rng1uyNnaVNMhOBbBW/UHEGVT2l93lu89svKGJSPqm8brykeqK5DrEulc00 qL5X3V3ME7SVBYUlDu42EWWyWWPbMtXXFVjNWM4AdgHlwP764v5a5rV1O/5wtDzZEnQV 96lmxBmMFmcxjq2Fsmp0mnyCiTzZN4qmv74u4CtjX0JTRpZiZvjIUAbepTjLryWi9sIu xvCkZFpc7cdwogXwfxfSfP1DCtoThQc4A0OH2sV5CwisO2GovUAA8Xzq+dqk+UXoJ28M veNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VgcMn06b; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e2-20020a17090301c200b0017676f11aebsi6018541plh.5.2022.09.28.06.34.46; Wed, 28 Sep 2022 06:34:59 -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=@gmail.com header.s=20210112 header.b=VgcMn06b; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233049AbiI1N1s (ORCPT + 99 others); Wed, 28 Sep 2022 09:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbiI1N1r (ORCPT ); Wed, 28 Sep 2022 09:27:47 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61CACA1D12 for ; Wed, 28 Sep 2022 06:27:46 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id z13-20020a7bc7cd000000b003b5054c6f9bso1246456wmk.2 for ; Wed, 28 Sep 2022 06:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=DnC6S+K0/VbM17qCQCLucty5V6KtRHnqqwh3CWVJLG4=; b=VgcMn06bI5M98yNrpL0TQVb9EzjLek7ha7a+Xn4CExuufd+xsLy4u0Ae7WB6SPKJbU /8EcZXSeAGlwUCY9/n/VtrAkOarb9SjMys9CbRnlnnLg0RiwgMnpcDoOeN769Bz8f86z hbyi0ueXOz7rNxSMxIRm1b25/VTjb2XSbTfhGBIJWVcO82mQBsmhDW/jU+szDpO/fWUX JzD6jvkbDTaR511965Vh256Ae1jmkvhXADxIZphpxYXfiRvc4KoyWK8F9D69L8M/WqzS qLMpWJfW30PlU/qB0ZsRWE6R4QkaVMMcBJKN3WBJqLCSjD30V6GJXC8dzNUVDuKDen3z wFyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=DnC6S+K0/VbM17qCQCLucty5V6KtRHnqqwh3CWVJLG4=; b=PAyq0dB8ExN9jO7+bE8glbLt9MeM1kFL+FctLc2KcDw8tunmmJypBj605Fjup7WXhO pzYmliGy5reKRsUR9asYPcNQNRKkXBzOAe8VN7mvawgLzQfUBYiF/9sZ6HtlIRRtxy35 z61zqRrDjyPenHjrfGSurItyyC3rBBf8W2eSp5staS4T344loVU6Bf+vG9AE0SO3cgEP GRdUyF9EipiYhHV2kAvJsHb/ivdtSz+oLGLOTXIQ4c11WQ/4rttj3X9Zk3v+xXyeKFBU W7kwCH+TPuNoKeqGOh9tTKnc9EGsJIk8bOraUYl2FiUy/JiICKqJa8BQ456qseNEpYyP MDhg== X-Gm-Message-State: ACrzQf0a27aaHk260FU8T7HySjwThpZ2NzhXbDzaLBPfhT2RngKEIeK2 VfbRiBFTEkRR3XjnGz9zEA== X-Received: by 2002:a05:600c:a04:b0:3b4:f20e:63f4 with SMTP id z4-20020a05600c0a0400b003b4f20e63f4mr6854132wmp.201.1664371664906; Wed, 28 Sep 2022 06:27:44 -0700 (PDT) Received: from octinomon ([2a00:23c8:2f02:3b01:3ea1:40:8650:189]) by smtp.gmail.com with ESMTPSA id e11-20020a5d4e8b000000b00228de58ae2bsm4221093wru.12.2022.09.28.06.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 06:27:44 -0700 (PDT) Date: Wed, 28 Sep 2022 14:27:42 +0100 From: Jules Irenge To: Greg KH 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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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, Sep 27, 2022 at 08:06:55AM +0200, Greg KH wrote: > 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 Thanks for feedback. I just sent a different version. I will appreciate any more feedback. Thanks, Jules