Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1300658rwb; Wed, 28 Sep 2022 16:34:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Idw8b5soc9BU+tohXiKMjDoJN+zkwtb8sT79YTz+k3kArnVFKFCZgV7pzOQJXf25bIJpZ X-Received: by 2002:a17:907:2707:b0:781:cfa5:18f with SMTP id w7-20020a170907270700b00781cfa5018fmr267953ejk.501.1664408098078; Wed, 28 Sep 2022 16:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664408098; cv=none; d=google.com; s=arc-20160816; b=LspASfw6FVHDIr+2DllSRyTVbl+BObSTXq5mfsT9Ay0UulPCT20UYT7iMHDtkZe4ny DokQ70ai7MxQfYCXWN69i7Se/qsTZ9po+ZTRvg2vfOYx4MNwWHSnv9ZUFymHBeBZAD7S CmEz+CCoc6anSC+Lq1ss3ywUJ1mMcNFBfKoRBx5KOtVIgox9J6gK4r3MFyQgl/khr9S3 NGkJediiWshuODldkMw0YjIVKidnBV15FIPmqJqr+0xTws0INJ2p9ND5FoupWvVLKaU+ 7f5xTYbmQb4t3M7/YuyX5a2yDLAmBxttsrj2zVdPwk+c/pyWLGUYvI5cZMMmqb8Hp9vm cLNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=t4unCVG2UmjVeD32nOkKb9SKjEr9pIuqlpFNKSuMRo0=; b=rJa2bzFrPmAYzxq24QlfzZgCRFNkIlGHxCILOkYTV5bxTwOgZ3/fbFxlHnzu1QPsVy aY+BSEZzyKhb6i+tyFStEyE+Wg94M7//CckVw41gfXNk9bhX30TydcUd6YYucOxJXf5i 9SQhyt9CTnWLA7g9v8ipOzsu3Pacjn0okunAPuyLz62UyMA7GXASWNZTd27itjlEuA6X AjzxNJeg4v+EaxIB6eCHPM//BQQmJkoNBTXmC3AfT9/Ty40Zx8vCH+XU/3LkOeEnKAgz 7GEQ1kYa7AXydrofE48jf0HD38xg7oQRulVt2HPdCJi4C66fMI9y1C18LIa5Rn4XE8Qb qKuw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt10-20020a1709072d8a00b007813b1924casi6460521ejc.292.2022.09.28.16.34.32; Wed, 28 Sep 2022 16:34:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbiI1XEO convert rfc822-to-8bit (ORCPT + 99 others); Wed, 28 Sep 2022 19:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbiI1XEM (ORCPT ); Wed, 28 Sep 2022 19:04:12 -0400 X-Greylist: delayed 243 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 28 Sep 2022 16:04:12 PDT Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C82F857C8; Wed, 28 Sep 2022 16:04:11 -0700 (PDT) Received: from omf15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 42F1F810C9; Wed, 28 Sep 2022 23:04:10 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf15.hostedemail.com (Postfix) with ESMTPA id C450B1A; Wed, 28 Sep 2022 23:04:01 +0000 (UTC) Message-ID: <46a600465f08edbda7d413f6dd0b1b1edd57cfa4.camel@perches.com> Subject: Re: [PATCH 3/7] s390/qeth: Convert snprintf() to scnprintf() From: Joe Perches To: Alexandra Winter , Jules Irenge , borntraeger@linux.ibm.com Cc: svens@linux.ibm.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, agordeev@linux.ibm.com Date: Wed, 28 Sep 2022 16:04:07 -0700 In-Reply-To: References: <5138b5a347b79a5f35b75d0babf5f41dbace879a.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Stat-Signature: 77c4p56xgruk3p35i1uacr4yaetb35qj X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: C450B1A X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18eEEanHqR4OnqcwMowgOsKUxuaq/Kzxbo= X-HE-Tag: 1664406241-228711 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, 2022-09-28 at 10:24 +0200, Alexandra Winter wrote: > On 27.09.22 16:27, Joe Perches wrote: > > On Mon, 2022-09-26 at 19:42 +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. > > [] > > > diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c > > [] > > > @@ -500,9 +500,9 @@ static ssize_t qeth_hw_trap_show(struct device *dev, > > > struct qeth_card *card = dev_get_drvdata(dev); > > > > > > if (card->info.hwtrap) > > > - return snprintf(buf, 5, "arm\n"); > > > + return scnprintf(buf, 5, "arm\n"); > > > else > > > - return snprintf(buf, 8, "disarm\n"); > > > + return scnprintf(buf, 8, "disarm\n"); > > > } > > > > Use sysfs_emit instead. > > > > Thank you Joe, that sounds like the best way to handle this. > I propose that I take this onto my ToDo list and test it in the s390 environment. > I will add > Reported-by: Jules Irenge > Suggested-by: Joe Perches > Thanks. btw: I was careless when I wrote one section of the proposed patch. In this patch block, @@ -467,28 +478,31 @@ static ssize_t qeth_dev_switch_attrs_show(struct device *dev, The last line + return sysfs_emit_at(buf, len, "\n"); is not correct It needs to be changed to: len += sysfs_emit_at(buf, len, "\n"); return len;