From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 500F0C433EF for ; Wed, 13 Oct 2021 09:27:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D7F9C61040 for ; Wed, 13 Oct 2021 09:27:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D7F9C61040 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3F4AF6B006C; Wed, 13 Oct 2021 05:27:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A5416B0071; Wed, 13 Oct 2021 05:27:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2941A900002; Wed, 13 Oct 2021 05:27:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 1A63E6B006C for ; Wed, 13 Oct 2021 05:27:47 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CB8528249980 for ; Wed, 13 Oct 2021 09:27:46 +0000 (UTC) X-FDA: 78690886932.03.F96BA67 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf02.hostedemail.com (Postfix) with ESMTP id 8D95E7001A05 for ; Wed, 13 Oct 2021 09:27:46 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id c16so9062809lfb.3 for ; Wed, 13 Oct 2021 02:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lGu4gibau1/RHAHGZaO32JXFLBHBAYsMHdCD0UNtmR4=; b=2/zm+iIEo+hlKe87R9gQCsh5w2uXYwocsvq4XVzknItNlRNgXY3/n+Jrbv0x9C08+A O7pRDoMe2tpBKGOumbDMBTpb7ZM09tU9G+9af2RWuOpFGw36YRJ6XPRIEsoJ8XqyVVlj suFF6qBE2HnXIhrelZWrMdyUNN2v3/oMgFSXUgZh8lCl6qn5T3c+1b25yXjse3qV6dlj ILXZiGud/oIzH+022yTIX3/vZGBiR7m243/mtfgtx72FL2ZPYF3gz6JZ3K/zvZ2rxojX KOh7dkTUihnQ5Z8s2DY6QVMDPT1lTdkILwvecrDfCu39mZBhGse01b0GglNYSuveQFVy M1iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lGu4gibau1/RHAHGZaO32JXFLBHBAYsMHdCD0UNtmR4=; b=qBiCMKz91rHb+ONnrCiWy7ViAjKCiPT++6TDQMW0Wgiv+IKdgwEvi0abKXqpjZc/rA k1SGlIGnHgfb0SeFSt9/vVKAQhIZuDoJkKbJEqvGRT5C5GYbQ0Kq9vULC9vNqWzQb0AD GTpXyxlOIIuTNnt34XwTlaoeh9OACJSVG8HrDyl9x2MsVDT2Jjv4e88xL7HUvRE7/h4Z XF2vnK4e7tLj8PHUDr9klaMFGXaWHUCw2MExCztbOjcNri8nDTS+4JFza8b2iRcBjCbi dbUiJ8xVkIonp7lgmwxgDMT7pRqK1dIJuYE67ZZwUIx1iTtTVNVdbn+SfUYy0R/bw+Xq fSzg== X-Gm-Message-State: AOAM533ENG4ghPVvj1Y7RjndVAJa2fh6GUZvXnoqudNc75iokOptFA2a xv8E8V8xUpfWStN07xPbZqZqXg== X-Google-Smtp-Source: ABdhPJyHPD/5sp1BLQEnr0tT5f31GONf3Wvpv3oqHngODTQyj8rPniif9NsHXfHYrF+xEJz4tzPhww== X-Received: by 2002:a2e:b611:: with SMTP id r17mr35864293ljn.336.1634117265021; Wed, 13 Oct 2021 02:27:45 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id h19sm587132lfk.199.2021.10.13.02.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 02:27:44 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 34C4210310E; Wed, 13 Oct 2021 12:27:46 +0300 (+03) Date: Wed, 13 Oct 2021 12:27:46 +0300 From: "Kirill A. Shutemov" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , Linux MM , Vlastimil Babka , Rasmus Villemoes Subject: Re: [PATCH 4/5] test_printf: Append '|' more efficiently Message-ID: <20211013092746.fqmvv7zlns334ajd@box.shutemov.name> References: <20211012182647.1605095-1-willy@infradead.org> <20211012182647.1605095-5-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 8D95E7001A05 X-Stat-Signature: 7uhkyyaiz99ui3cpero13b68bjeehmqq Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b="2/zm+iIE"; dmarc=none; spf=none (imf02.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.167.49) smtp.mailfrom=kirill@shutemov.name X-HE-Tag: 1634117266-977693 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Oct 13, 2021 at 01:22:10PM +0800, Yafang Shao wrote: > On Wed, Oct 13, 2021 at 2:33 AM Matthew Wilcox (Oracle) > wrote: > > > > Instead of calling snprintf(), just append '|' by hand. > > > > Signed-off-by: Matthew Wilcox (Oracle) > > --- > > lib/test_printf.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/lib/test_printf.c b/lib/test_printf.c > > index 60cdf4ba991e..662c3785aa57 100644 > > --- a/lib/test_printf.c > > +++ b/lib/test_printf.c > > @@ -623,9 +623,9 @@ page_flags_test(int section, int node, int zone, int last_cpupid, > > if (!pft[i].width) > > continue; > > > > - if (append) { > > - snprintf(cmp_buf + size, BUF_SIZE - size, "|"); > > - size = strlen(cmp_buf); > > + if (append && size < BUF_SIZE) { > > Should it be: > if (append && size < BUF_SIZE - 1) > ? Yeah, looks like off-by-one to me. -- Kirill A. Shutemov