Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3601269pxj; Tue, 1 Jun 2021 08:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypUG3TjTckv92ELLKPXBCr+V1tWWTYa/aB9NDjxIeZulRyPaGjjrmC/I79DFauzpk2WxtY X-Received: by 2002:a92:b111:: with SMTP id t17mr22532732ilh.208.1622562919212; Tue, 01 Jun 2021 08:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622562919; cv=none; d=google.com; s=arc-20160816; b=qYxFi7azKCAqEfFNJ+NYhG6rHulzMCtNlJtHm7aVN/N4GAGu1Ob5wn+PsHCxSpWN/C po31feJYDPgU7zCkyuPxDCeN6fW7poVfyXWajbTPmraVa2A6IJrWk7ndrWyE2GJtZN3m P+rBWpIPFNWYqC9Q9UmRJkECDHZlLqbLHwkx2PBxfmQDcTL5nM1UdoOgLUwyPDGQdMoD U+gzuOq5GejU+NZ9AU4B6SXzr4Wo71bXnpgXeyF62RLyFMVU83H4mxN6oY44CMgtSmfm paX+6l008hZs/O39w/g+/CzW/6CpdBi7A7O88rE2NhbvVUVo967iV3IEPk+oqMcmT1BU V8Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=jIW8h/z0uLD7leT4GHtmkmR3OFJ3smy9zNXkGmtXBTE=; b=Wb8ZLapXN5IJ1Gn2qN/hWd7TSkbXU8ZjKlEDgVfU59O3WQx1btHGrvh0+czFv1DHki tPHGheus3IbZqtoALeBLb55VN8ZJdl3jNuADBhNb0qsaHgRBVS/LT4nxxMMvFdOH9HKe 7AuNejMrMwYH/wX1dDMFFlZQKIegwDfQ8NBo0afZA3zXFfwm6zln3rqlHnSXHsD5gNPX eTZflid0XWXz9pJk/bHzfpx7cMkvHom5aMEOsmiD9sU4pL+6IY3rJq7XUUtwK206qELd dPTUDC9xDpp98D2NBMcoXOeRb1AqzwMbICW7hgyCQH9zl1V9Z/mmQQVpHwnlAyr/6C7d VALg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si16449375ilq.159.2021.06.01.08.55.03; Tue, 01 Jun 2021 08:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234544AbhFAPzS (ORCPT + 99 others); Tue, 1 Jun 2021 11:55:18 -0400 Received: from mga11.intel.com ([192.55.52.93]:39065 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234509AbhFAPzR (ORCPT ); Tue, 1 Jun 2021 11:55:17 -0400 IronPort-SDR: ysOsEbmTKQno7RQjY9aRNvzGWkpaV8ezyzN856CJXh0vskRQfbQfq+dEhDI9LLuqcGplAt8b2b Msi3bQAbBRVw== X-IronPort-AV: E=McAfee;i="6200,9189,10002"; a="200560722" X-IronPort-AV: E=Sophos;i="5.83,240,1616482800"; d="scan'208";a="200560722" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 08:53:35 -0700 IronPort-SDR: Dqsx7f1uf8eEqfpJipAwkdbFi00n1UDbgCGrF6mC7VyCqTu5jSg18Yw+zDV5veibAWiF0qkKwz D+OqBAJHwwwg== X-IronPort-AV: E=Sophos;i="5.83,240,1616482800"; d="scan'208";a="411282177" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 08:53:30 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lo6hq-00GTZB-Rc; Tue, 01 Jun 2021 18:53:26 +0300 Date: Tue, 1 Jun 2021 18:53:26 +0300 From: Andy Shevchenko To: Matthew Wilcox Cc: Justin He , Linus Torvalds , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes , Jonathan Corbet , Alexander Viro , Luca Coelho , Kalle Valo , "David S. Miller" , Jakub Kicinski , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Johannes Berg , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-s390@vger.kernel.org" , Linux FS Devel Subject: Re: [PATCH RFCv2 2/3] lib/vsprintf.c: make %pD print full path for file Message-ID: References: <20210528113951.6225-3-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Tue, Jun 01, 2021 at 04:44:00PM +0100, Matthew Wilcox wrote: > On Tue, Jun 01, 2021 at 06:36:41PM +0300, Andy Shevchenko wrote: > > On Tue, Jun 1, 2021 at 6:32 PM Matthew Wilcox wrote: > > > On Tue, Jun 01, 2021 at 02:42:15PM +0000, Justin He wrote: > > > > ... > > > > > Just don't put anything > > > in the buffer if the user didn't supply enough space. As long as you > > > get the return value right, they know the string is bad (or they don't > > > care if the string is bad) > > > > It might be that I'm out of context here, but printf() functionality > > in the kernel (vsprintf() if being precise) and its users consider > > that it should fill buffer up to the end of whatever space is > > available. > > Do they though? What use is it to specify a small buffer, print a > large filename into it and then use that buffer, knowing that it wasn't > big enough? That would help decide whether we should print the > start or the end of the filename. > > Remember, we're going for usefulness here, not abiding by the letter of > the standard under all circumstances, no matter the cost. At least > partially because we're far outside the standard here; POSIX does > not specify what %pD does. > > "The argument shall be a pointer to void. The value of the > pointer is converted to a sequence of printable characters, in an > implementation-defined manner." All nice words, but don't forget kasprintf() or other usages like this. For the same input we have to have the same result independently on the room in the buffer. So, if I print "Hello, World" I should always get it, not "Monkey's Paw". I.o.w. snprintf(10) ==> "Hello, Wor" snprintf(5) ==> "Hello" snprintf(2) !=> "Mo" snprintf(1) !=> "M" snprintf(1) ==> "H" Inconsistency here is really not what we want. -- With Best Regards, Andy Shevchenko