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 60FEEC433FE for ; Tue, 1 Feb 2022 16:02:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D99408D0072; Tue, 1 Feb 2022 11:02:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D49228D006D; Tue, 1 Feb 2022 11:02:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C12178D0072; Tue, 1 Feb 2022 11:02:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id B04438D006D for ; Tue, 1 Feb 2022 11:02:30 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7492D82138EC for ; Tue, 1 Feb 2022 16:02:30 +0000 (UTC) X-FDA: 79094678460.09.DCC1CF4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id EC9F340016 for ; Tue, 1 Feb 2022 16:02:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643731349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0lOsjYnjuXJjkQQPkdLRQ4+5wRRHj/4IS9YqFDRMAvI=; b=Jw3E49V/j4fkG+DDj3JcaDr2A8lPGKvcAVLj4fDbXsW7xycaMHDmaakfis8MM9BGYM4OEF lUkqdRZY7IT5hWwAkxd5FNNPFufOnVNYWGYy7piY7YfMgcIHE0xqCg9r5NiAFDNJBaV2jM 90K7jMrhN9cbp06zYZyaS4NkL9RUON4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-WqDDEl3dPKOc7sq2HX2xEg-1; Tue, 01 Feb 2022 11:02:27 -0500 X-MC-Unique: WqDDEl3dPKOc7sq2HX2xEg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2A3211966320; Tue, 1 Feb 2022 16:02:14 +0000 (UTC) Received: from [10.22.19.61] (unknown [10.22.19.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00CF772FA2; Tue, 1 Feb 2022 16:01:51 +0000 (UTC) Message-ID: Date: Tue, 1 Feb 2022 11:01:51 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v2 1/3] lib/vsprintf: Avoid redundant work with 0 size Content-Language: en-US To: Rasmus Villemoes , Andy Shevchenko , David Rientjes Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Ira Weiny , Rafael Aquini References: <20220129205315.478628-1-longman@redhat.com> <20220129205315.478628-2-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Stat-Signature: hnbuc4f3jso3wc97be7g1nrwow86simg X-Rspam-User: nil Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="Jw3E49V/"; spf=none (imf04.hostedemail.com: domain of longman@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EC9F340016 X-HE-Tag: 1643731349-902261 Content-Transfer-Encoding: quoted-printable 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 2/1/22 02:12, Rasmus Villemoes wrote: > On 31/01/2022 19.48, Waiman Long wrote: >> On 1/31/22 05:34, Andy Shevchenko wrote: >>> Also it seems currently the kernel documentation is not aligned with >>> the code >>> >>> =C2=A0=C2=A0 "If @size is =3D=3D 0 the function returns 0." >>> >>> It should mention the (theoretical?) possibility of getting negative >>> value, >>> if vsnprintf() returns negative value. >> AFAICS, the kernel's vsnprintf() function will not return -1. > Even if it did, the "i < size" comparison in vscnprintf() is "int v > size_t", so integer promotion says that even if i were negative, that > comparison would be false, so we wouldn't forward that negative value > anyway. > >> So in that >> sense it is not fully POSIX compliant. > Of course it's not, but not because it doesn't return -1. POSIX just > says to return that in case of an error, and as a matter of QoI, the > kernel's implementation simply can't (and must not) fail. There are > other cases where we don't follow POSIX/C, e.g. in some corner cases > around field length and precision (documented in test_printf.c), and th= e > non-support of %n (and floating point and handling of wchar_t*), and th= e > whole %p<> extension etc. > > Rasmus > Thanks for the clarification. Cheers, Longman