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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3DC2C47096 for ; Tue, 1 Jun 2021 15:45:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B456861026 for ; Tue, 1 Jun 2021 15:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233059AbhFAPrA (ORCPT ); Tue, 1 Jun 2021 11:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbhFAPq6 (ORCPT ); Tue, 1 Jun 2021 11:46:58 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A40EC061574; Tue, 1 Jun 2021 08:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pGxMEf6cI2zmD9A2dr6Kcpgggt5wOUbfj+KDV5ZubZY=; b=NiDf3wGs/Dj5kjAPmbl4MKtYo+ a8b0jBJbKLjq3hxLXq1Doy+fC4Pthit/xOi7d0QLc+aqukDU51f9w8zpPP4+8yfaSdryX3eDRWLNZ pv7rFzdASFxJZ0pSqYv6uOBAnToIdRvYC4qzLPfeGNogN30PAEr7rGRlDtxPCjX0vxtgUUEnM86zu PUgrOvaIptk4S8FbhZwyri9zczlYuOB27S0opY/UPCCKdmqyf3ZhpClumu4OCo3xvjuJUwzCIO+Au AalERUlqMwibyjmQdFhiHRC/7fiOieFmnBOgCSjEclDY9ko7njzupUhqVvcOroRFcIDcKvQu++meI 1Vosh+ZQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lo6Yi-00AAfU-PH; Tue, 01 Jun 2021 15:44:05 +0000 Date: Tue, 1 Jun 2021 16:44:00 +0100 From: Matthew Wilcox To: Andy Shevchenko Cc: Justin He , Linus Torvalds , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , 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-1-justin.he@arm.com> <20210528113951.6225-3-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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."