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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBF30C433EF for ; Tue, 8 Feb 2022 10:08:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77D5F8D0003; Tue, 8 Feb 2022 05:08:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72B718D0001; Tue, 8 Feb 2022 05:08:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61B018D0003; Tue, 8 Feb 2022 05:08:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 529838D0001 for ; Tue, 8 Feb 2022 05:08:22 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1A017181F10FF for ; Tue, 8 Feb 2022 10:08:22 +0000 (UTC) X-FDA: 79119187644.10.6196A58 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf14.hostedemail.com (Postfix) with ESMTP id 9D47910000A for ; Tue, 8 Feb 2022 10:08:21 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 76BA61F388; Tue, 8 Feb 2022 10:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644314900; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ePNInOzC6B5yJASGd/cwztAJV06U48l5tV+fyrVP+Cs=; b=UUqjWtY9SCXAhFmVatTniPu2rGbqj9soOjeMqZZUKgqY0wGYEx99UAcgCBeWBfXuqinAUR CuI6xMeqwBDeZyaUWLf68hyGwMFwu0aZZSiHHYuq5MyqmyaTx8PSttFuah16OymkTYBciv 2ub3JHIEYPTnLJ9em/aYA989OP2dRbY= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 07731A3B87; Tue, 8 Feb 2022 10:08:20 +0000 (UTC) Date: Tue, 8 Feb 2022 11:08:18 +0100 From: Petr Mladek To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Mike Rapoport , David Rientjes , Roman Gushchin , Rafael Aquini Subject: Re: [PATCH v4 1/4] lib/vsprintf: Avoid redundant work with 0 size Message-ID: References: <20220131192308.608837-5-longman@redhat.com> <20220202203036.744010-2-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220202203036.744010-2-longman@redhat.com> X-Rspamd-Queue-Id: 9D47910000A X-Stat-Signature: rd9z4etr48h4cwi9jtayzn48iakdwtsu X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=UUqjWtY9; spf=pass (imf14.hostedemail.com: domain of pmladek@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=pmladek@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam05 X-HE-Tag: 1644314901-418910 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 2022-02-02 15:30:33, Waiman Long wrote: > For *scnprintf(), vsnprintf() is always called even if the input size is > 0. That is a waste of time, so just return 0 in this case. > > Note that vsnprintf() will never return -1 to indicate an error. So > skipping the call to vsnprintf() when size is 0 will have no functional > impact at all. > > Signed-off-by: Waiman Long > Acked-by: David Rientjes > Reviewed-by: Sergey Senozhatsky > Acked-by: Roman Gushchin Reviewed-by: Petr Mladek Best Regards, Petr