Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2555412ybp; Sat, 5 Oct 2019 14:49:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzD7Ld9HVq0buZiT291p3HFhWtF5SK4ymBUCZwQXo9JkSX7nJUqLC3cJJ8MtTI529/MPhn X-Received: by 2002:a50:f747:: with SMTP id j7mr22171927edn.73.1570312187691; Sat, 05 Oct 2019 14:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570312187; cv=none; d=google.com; s=arc-20160816; b=I2NYZw+yO+7NepJqDpf6jrWYoaZOijOrsRHTcoRfyk+S+YRzLh9Wv2bn0ROc3lOX1x 4zCV6bodYfQVpzS8M7TJBCWG5aRPtij6hzu2fp9Wko4onW2oYYgAqJR+yvXEC89DAPK4 3e9SktICCRBgcSrQfAAlHhUzPemj4JbQ+Uua3G1wVGrb78GtSnQB6jTesEhoS6lQgU+x piR6lYal5ynbkr2vSYCry6mlY8NNQz4Rz3yKUPr1fSbb1vwrjz3ckw/uWUNXlsgGX1Dj qlQH442Mhw04tCLv3Zqp43Aq+3vN4UgqIEO76GzHrYQRhHm5lbBhef8WJWgtWi8rRIYX eACw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=wa8STetquLZl1IAaLhPCrzppaRNCTmvqA2gWR0hTK28=; b=WUui4eF8iYXNhALbh0kZJqxdYIlIviTR8LrLQlgOUROXNU+8bN1ed7dKNtox8Hw6UR +kiK7XyiztUQke/ZUOVsTOBVEgoYETcc8wnQU6XZ2i8B5oalYq+punZ4zMI9WqlDhhRz E7eOI2XrrvVub2UV1aOEUjiPaAziBlDJuHUuuSm8B7+72VRSzZYVFeM2B7JlKwsMuobY t3aMRE837fTbwL7CkT1G/d/7mRKm63c60z2VbP9JQVnbCPDuyWJN+8zBpsweMCMFgwt1 lKazO6+PLZYY+uD6l/x2wvu7bzcRyxn2+AQ2skHaZdd90o1NRQ+I1pe2FdRa1hC9DOMu lwKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=09sGzm+T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si5073735eja.38.2019.10.05.14.48.45; Sat, 05 Oct 2019 14:49:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=09sGzm+T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725947AbfJEVsc (ORCPT + 99 others); Sat, 5 Oct 2019 17:48:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfJEVsc (ORCPT ); Sat, 5 Oct 2019 17:48:32 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 494D0222C0; Sat, 5 Oct 2019 21:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570312111; bh=HNhRg9C+uT8munplm6gItEmqRk2fzoMeetuPUipn458=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=09sGzm+TkX4yptOvFcUZkbVIfYJVinR8FNqinr3BNuPCm9QnXgBl25ss/I51or6+n dRjZCJYRrB9O7ZgSvm/k/Yca6R4Vzq6Hfk2pmpWSeYNfMan5hE+i4HKKh8zpVGNvY2 djLeN5GjdXIwt/0F+3LNDkESxOLCJdgIJLWz4fS8= Date: Sat, 5 Oct 2019 14:48:30 -0700 From: Andrew Morton To: Rasmus Villemoes Cc: Jonathan Corbet , Andy Shevchenko , Joe Perches , Petr Mladek , Sergey Senozhatsky , Jani Nikula , Linux Kernel Mailing List , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , linux-doc@vger.kernel.org, Pavel Machek Subject: Re: [PATCH v3] printf: add support for printing symbolic error codes Message-Id: <20191005144830.f94bc9d63001981c5eefe875@linux-foundation.org> In-Reply-To: <20190917065959.5560-1-linux@rasmusvillemoes.dk> References: <20190909203826.22263-1-linux@rasmusvillemoes.dk> <20190917065959.5560-1-linux@rasmusvillemoes.dk> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Sep 2019 08:59:59 +0200 Rasmus Villemoes wrote: > It has been suggested several times to extend vsnprintf() to be able > to convert the numeric value of ENOSPC to print "ENOSPC". This is yet > another attempt. Rather than adding another %p extension, simply teach > plain %p to convert ERR_PTRs. While the primary use case is > > if (IS_ERR(foo)) { > pr_err("Sorry, can't do that: %p\n", foo); > return PTR_ERR(foo); > } > > it is also more helpful to get a symbolic error code (or, worst case, > a decimal number) in case an ERR_PTR is accidentally passed to some > %p, rather than the (efault) that check_pointer() would > result in. > > With my embedded hat on, I've made it possible to remove this. > > I've tested that the #ifdeffery in errcode.c is sufficient to make > this compile on arm, arm64, mips, powerpc, s390, x86 - I'm sure the > 0day bot will tell me which ones I've missed. > > The symbols to include have been found by massaging the output of > > find arch include -iname 'errno*.h' | xargs grep -E 'define\s*E' > > In the cases where some common aliasing exists > (e.g. EAGAIN=EWOULDBLOCK on all platforms, EDEADLOCK=EDEADLK on most), > I've moved the more popular one (in terms of 'git grep -w Efoo | wc) > to the bottom so that one takes precedence. Looks reasonable to me. Is there any existing kernel code which presently uses this? Can we get some conversions done to demonstrate and hopefully test the feature?