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 3AE31C4338F for ; Thu, 19 Aug 2021 14:16:28 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D48C610FA for ; Thu, 19 Aug 2021 14:16:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2D48C610FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 266C081FC6; Thu, 19 Aug 2021 16:16:25 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629382585; bh=8Qzi9OpH3Kvtv7ndSbhqU+tMEKNn4lPg39toNaV9z3g=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Mo7VIjTl1itbOTPLNAIRx9utpor1hnm6Gk19NvaXJBiV41vdWZYe+a4Djw25XRt5L CEqZOLd2UmFBlPqAoibFuZN74OSYDSANOFn8Jbc8pTBB5hIMwS7VBedWJVy6egnKXe tHGyrOQnOsqPmB0vEbebYBmEP/6yfxv18e0uD8VO7mEK5PUzo8jCNN2Te+u+bO9U52 1gR/tiv6YORmTazgo7JRvGDOnylxs+SPvPrzDXkcIGyOCTUVs4BdSiAaXSg0P99Hp9 01cXIPJSm6tQ7bwIX3u6X5EmLx4N+KtYOhYZ260V8snStNBapvcNP9paL+5n87HzI7 SvWYoXQ8ew7rw== Received: from janitor.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: noc@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7DF2A81F7B for ; Thu, 19 Aug 2021 16:16:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629382582; bh=8Qzi9OpH3Kvtv7ndSbhqU+tMEKNn4lPg39toNaV9z3g=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=blxyu75PcV9oYvOuqqkM8ryvzL1Rmbz8xGYC4s8tuXpX7T5BOq6UQ43X7aWUik9qM JY7ws9f22fUsGiM4jxAfjfYFAnyMKeTgKb3AE30TwAUw3KTTQFsN/IlmY5KSOzzf8q oDOhrz3gAMHfZfYWZmkQt4bDj5Jsk+LCPbl3+sa3zxeiYA1f4OP1kgAdcOlfcMSHWN mUMP1Wo4NiWjP5lVVSXw5/QcldkuYrN81xoM8wm0ECbFsyZ+8xzocqDX9AARy6OqBo qmGi8GLrcUkPGU7y2qZ2gNXAzwMUWMHGsaQzNzDOp0H+J1OqPdE/PHoI5yeF6kDMj6 Mj1MFZ7/RW87Q== Received: by janitor.denx.de (Postfix, from userid 108) id 28A38A0156; Thu, 19 Aug 2021 16:16:22 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id 50F01A005F; Thu, 19 Aug 2021 16:16:12 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id 242C31E1774; Thu, 19 Aug 2021 16:16:12 +0200 (CEST) To: Tom Rini cc: Rasmus Villemoes , u-boot@lists.denx.de, Simon Glass , Stefan Roese From: Wolfgang Denk Subject: Re: [PATCH v6 10/12] watchdog: add gpio watchdog driver MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8bit In-reply-to: <20210819130806.GW858@bill-the-cat> References: <20210819095706.3585923-1-rasmus.villemoes@prevas.dk> <20210819095706.3585923-11-rasmus.villemoes@prevas.dk> <57359.1629373593@gemini.denx.de> <62540f7b-0e07-8759-8e12-125527c2edec@prevas.dk> <61767.1629376321@gemini.denx.de> <20210819123540.GV858@bill-the-cat> <64046.1629378226@gemini.denx.de> <20210819130806.GW858@bill-the-cat> Comments: In-reply-to Tom Rini message dated "Thu, 19 Aug 2021 09:08:06 -0400." Date: Thu, 19 Aug 2021 16:16:12 +0200 Message-ID: <66367.1629382572@gemini.denx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Dear Tom, In message <20210819130806.GW858@bill-the-cat> you wrote: > > > So we have now a policy to wave through code, and ask others to > > clean it up later? That's ... sad. > > No, we continue to have the policy of expecting reviewers to follow the > whole discussion and relevant subsystems. Once upon a time there has also been a policy that if a function might return error codes, these need to be checked and handled. > Changing _every_ caller of dev_get_priv to check for NULL and > then, what? is clearly not the right answer. Then what is the right answer in your opinion? I mean, look at the implementation of dev_get_priv(): 628 void *dev_get_priv(const struct udevice *dev) 629 { 630 if (!dev) { 631 dm_warn("%s: null device\n", __func__); 632 return NULL; 633 } 634 635 return dm_priv_to_rw(dev->priv_); 636 } If there is guaranteed no way that dev_get_priv() can return a NULL pointer, that means that it must be guaranteed that the "dev" argument can never be a NULL pointer, either. So why do we check it at all? The same applies for all functions in "drivers/core/device.c" - they all check for valid input parameters, like any code should do. > If you think you see a problem here please go audit the DM code > itself more and propose some changes. I can see that the DM code itself implements proper error checking and reporting; it's the callers where negligent code prevails. If you are consequent, you must decide what you want: - Either we want robust and reliable code - then we have to handle the error codes which functions like dev_get_priv() etc. return. - Or you don't care about software quality, then we can omit such handling, but then it would also be consequent to remove all the error checking from "drivers/core/device.c" etc. - hey, that would even save a few hundred bytes of code size. Sugarcoating code which fails to handle error codes because "these errors can never happen" does not seem to be a clever approach to software engineering to me. I stop here. You know my opinion. You are the maintainer. Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de A witty saying proves nothing, but saying something pointless gets people's attention.