Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3615718pxj; Tue, 1 Jun 2021 09:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzUXZ0qMcdpVcqTfiUTXwLYrX5rTdVAVdYrdJEMHKHaGLX+P1cdgHYckqavuyVi7voC4jx X-Received: by 2002:a05:6e02:2192:: with SMTP id j18mr21656162ila.223.1622563954823; Tue, 01 Jun 2021 09:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622563954; cv=none; d=google.com; s=arc-20160816; b=cHz+/TTAFxuA0mJN87SY2SCGbVixd05PU6Xzl2BZpPE4QQZDsm3zUW3o3iLnMfGmFj uOj3jNEvR9EA4GWUAiiYKDw/PWd2L9V0K8bi+Y7f3lmMinf2cVU6UA3g5K5n2dSiEih0 D5M97pfW3eztOYNDOUGver65qJ34JZHydI+gnxBl73te2kcA9Hp9dNHCX4dxWbXHxqmA OXqYvrCRZ0YhDC924jE1qHZFc3TVmhiRFfA594WWcvd6A1hRR2ZtIbu2eaTlyT6ESK4M ioIPjQUf7XrYzdXQMmrR4maEtQaQwQBSZIhEX2QOaOj5embwgwTtoxqR2bXw1LOfhBqs oVfg== 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=VxbX9Wfed9vFfNnh9ZM6SVNEgJWyU5xiVzvMYl8FASg=; b=VFTKh33cfgPPSUTrGwvzIjDrPF9F7cAciVi4N9oDZKXyXgMgDX/7gQO5TJLpetILrL DO5vhGAuccrboBjEFUWhMm3QAK/PoURWqIAGe00wh7+Y/qTITXBmfSlyhochxfKnH5Em H3nDytxwtnkR2T//us3Fftb//T9/kBVDKbdFFL1dYcYsQq3ooXI8LRcHJpIBa6cSW/fs gePjl62WUS+ifTb+kmhHp7W44O8iftXY68JVNVO/LsyqWb5OujsaZq5HHdAk10uqXWSE RE8DERNEg3Xz6BiHorySzWBO8FX1Ir9CZHY9UWB3cb68kg17VBHXzyK/BkpxLSTlGotZ 08Kw== 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 h17si18375835ila.72.2021.06.01.09.12.18; Tue, 01 Jun 2021 09:12:34 -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 S234209AbhFAQNq (ORCPT + 99 others); Tue, 1 Jun 2021 12:13:46 -0400 Received: from mga11.intel.com ([192.55.52.93]:40749 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhFAQNp (ORCPT ); Tue, 1 Jun 2021 12:13:45 -0400 IronPort-SDR: 6Dkv8BuOKeY+L7xXcEHmzPTLyKWGWDZixwFkq9yD2vweJlIYLn6oQPK8dNSfT9EL/8mStwBcrJ oD1Tl+0XTZhQ== X-IronPort-AV: E=McAfee;i="6200,9189,10002"; a="200564663" X-IronPort-AV: E=Sophos;i="5.83,240,1616482800"; d="scan'208";a="200564663" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 09:10:50 -0700 IronPort-SDR: p6iGhjR6RZGIaThSJIMsrDMkBC2yTJlyRQMHAQQu9Ss7eIs9YVt2ec8zXDcXUzwZchHJzXPSuv K1tCePzPVo4Q== X-IronPort-AV: E=Sophos;i="5.83,240,1616482800"; d="scan'208";a="549777277" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 09:10:45 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lo6yX-00GTkz-TQ; Tue, 01 Jun 2021 19:10:41 +0300 Date: Tue, 1 Jun 2021 19:10:41 +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: 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 06:53:26PM +0300, Andy Shevchenko wrote: > 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. I have to add that in light of the topic those characters should be counted from the end of the filename. So, we will give user as much as possible of useful information. I.o.w. always print the last part of filename up to the buffer size or if the filename is shorter than buffer we will have it in full. -- With Best Regards, Andy Shevchenko