Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5579862imm; Tue, 16 Oct 2018 12:31:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV60vq3OJiTi9T51uETih+Jisc6zUeOX73gMCA5NKWUzNFUZAdMd/h4nM1Mo97cTDHog4fDWn X-Received: by 2002:a62:aa17:: with SMTP id e23-v6mr23494856pff.211.1539718272166; Tue, 16 Oct 2018 12:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539718272; cv=none; d=google.com; s=arc-20160816; b=c3u9fefbvTGaRvMy8VZKKCzxb7PyCN2ixssyTFtzGAlAjI/vdzGNvb1BYBsPI09t2s v/Y25Eh3gN9/24SOzkUCjgUnK1a96j99nqtsszJ+cmRL466zN6gyT7FG3z8dbiAtxk7j 6SRilx9JBbPGarRZkTUTCX91/eaWvM1Bm4kfyazbSEA+efDR5n+uKidfyQmIFDdeywTP Lixy0OHJ20SEvnibDbYw2eiW1l9Re3zRqC22LWr0a0/9okb9vMyoSAX1sVAPCSy6ilyR 2RG+d8rwBfRLJJo64FAXzyz4kkTRK2E9+LywY+V37M86pQvwkBfoUltLCDCmrDW04Rca 1QNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=nRfHh0YwwaVOfGvgHL3HJFxhiEFiKuMGM/WhoBgUiUw=; b=ymFa83hP3F9XsLngrFVqaHKA4BBY766vrwcJIhBBaRaOF94/qzmAzDhaXPWyiWectH tDgg5gbmT7KvBhc0bNbrvV2/G3FGEexqP8ngN9QU+vLfawld4mJ3nnT8L4k7nMLhYrof eLWxdcurkFzTw5woMn1S0WqdhOxy2Vxdi3obSNoTNvZKv+MhnKLDLgddJeit557ahU62 xMyKqOjqWXEVua5CXlVXTCqai7X5fHRsJNWYJ/5HhRh+JjI4zCh/l5SQ7ec6dgQtKxHk T5snfkBTWFCIDJ/C5X70dh/tIIlVsk5MzW2Vfri/UpUd920yjVZqQIkfeOU2Jr/Jyt6Z HBUA== ARC-Authentication-Results: i=1; mx.google.com; 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 y34-v6si15086863plb.46.2018.10.16.12.30.56; Tue, 16 Oct 2018 12:31:12 -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; 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 S1727280AbeJQDVc (ORCPT + 99 others); Tue, 16 Oct 2018 23:21:32 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:48859 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbeJQDVc (ORCPT ); Tue, 16 Oct 2018 23:21:32 -0400 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gCV21-0006MG-Vv; Tue, 16 Oct 2018 21:29:29 +0200 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gCV20-0002WU-EZ; Tue, 16 Oct 2018 21:29:28 +0200 Date: Tue, 16 Oct 2018 21:29:28 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Al Viro Cc: Alessandro Rubini , Michal.Vokac@ysoft.com, corbet@lwn.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, thierry.reding@gmail.com, kernel@pengutronix.de, akpm@linux-foundation.org Subject: Re: [PATCH RFC] err.h: document that PTR_ERR should only be used if IS_ERR returns true Message-ID: <20181016192928.pinjwxfors4reigh@pengutronix.de> References: <20181014202807.16412-1-uwe@kleine-koenig.org> <20181015093708.GA22876@mail.gnudd.com> <20181016180650.GZ32577@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181016180650.GZ32577@ZenIV.linux.org.uk> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 16, 2018 at 07:06:51PM +0100, Al Viro wrote: > On Mon, Oct 15, 2018 at 11:37:08AM +0200, Alessandro Rubini wrote: > > > OTOH I admit you can compare any value with -EINVAL, after PTR_ERR. > > But in general you first detect the error condition and then split > > among error (or print a message according to the exact value. > > if (IS_ERR(p) && PTR_ERR(p) == -ENOENT) > instead of > if (p == ERR_PTR(-ENOENT)) > > is ugly, obfuscating what's going on for no good reason and I'm going > to keep killing those every time I run into one... And what do you do if you see a p = somefunc(...); if (PTR_ERR(p) == -ENOENT) without first checking for IS_ERR(p)? Another alternative is if (PTR_ERR_OR_ZERO(p) == -ENOENT) ? In your eyes, should they all be converted to if (p == ERR_PTR(-ENOENT)) ? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |