Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp79113yba; Thu, 2 May 2019 20:18:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3e0j7xbfjFo6QAw/qWjuFCfASGxoqyo+PQzvKYptFyq0zCEApMX6iQOlDyW0AnZoHRvtg X-Received: by 2002:a63:6849:: with SMTP id d70mr7389940pgc.21.1556853498861; Thu, 02 May 2019 20:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556853498; cv=none; d=google.com; s=arc-20160816; b=YkmKHZ1oWH0OzcM4Uv9I5ZMLrqejwoKstodbE37raCQeIqtZtoTRYyk0EfuJeBZTGx L4YPOUWHWjee1Q3JmQu5H1Pk1x8zK2AkUz3JdcMh1WD7fiN8LM27P2Mv+zGkFxfu8eTW HJ3/6K18/HFAgYm6NENzG5mUPF4VmhXcBeyTjlUcbd/kGT0iTevELsPSREK7Hgb7Ix4t Urw/96DhRrrkIQX0W+seSvyGWLKvaymxiGBA5WOMpFEyjG6+7OwXc22LnPRRfNpm2Hkx TTvDj2byPnjXkwA72+CZh6SECw4jZNTz2HPrbDkGZ+W8fp6Eo0Z0BCVd6Zjr4h4jb+78 goig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=xbtSM5dinjPZAqNfUh/zqypYKWJ28QNVWzzJ8Rp/d7M=; b=cAbDeNs4QMAYtfLd9rgj3yh4D5cNlpdrNZuQU9pV9E51X8QtXLfPkKZoRthyER3uDr D+5sPsr0XIJhj8HznWl/Ym556jbKn9VLmhit1liAjFEpjMT07ra3xXqf0qsQMKgF/Yhb Q8sFdjYklNSQAOP7Jzkrab/fuahEm4HoR8gGWDAsQ3C1Sz3T72zaQNMuj9NltRQq3avG huDezig4iPCdqs7zp94wS50sF5H1Z4HRMF0p+Ziz8ktJkX0yPlcoaOutpo0EA8dc/i4i PaQKIrUnyGqNPK1rZiZpaWDf4loGbfF1d05ofFb+jm+2oPUA2yim2QxOVadB6kUG6mRl Pu5A== 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 t5si990881plq.83.2019.05.02.20.18.03; Thu, 02 May 2019 20:18:18 -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 S1726423AbfECDPT (ORCPT + 99 others); Thu, 2 May 2019 23:15:19 -0400 Received: from ale.deltatee.com ([207.54.116.67]:38140 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbfECDPS (ORCPT ); Thu, 2 May 2019 23:15:18 -0400 Received: from adsl-173-228-226-134.prtc.net ([173.228.226.134] helo=[172.20.29.49]) by ale.deltatee.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hMOef-0006md-Tg; Thu, 02 May 2019 21:14:35 -0600 To: Brendan Higgins , frowand.list@gmail.com, gregkh@linuxfoundation.org, keescook@google.com, kieran.bingham@ideasonboard.com, mcgrof@kernel.org, robh@kernel.org, sboyd@kernel.org, shuah@kernel.org Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-um@lists.infradead.org, Alexander.Levin@microsoft.com, Tim.Bird@sony.com, amir73il@gmail.com, dan.carpenter@oracle.com, dan.j.williams@intel.com, daniel@ffwll.ch, jdike@addtoit.com, joel@jms.id.au, julia.lawall@lip6.fr, khilman@baylibre.com, knut.omang@oracle.com, mpe@ellerman.id.au, pmladek@suse.com, richard@nod.at, rientjes@google.com, rostedt@goodmis.org, wfg@linux.intel.com References: <20190501230126.229218-1-brendanhiggins@google.com> <20190501230126.229218-9-brendanhiggins@google.com> From: Logan Gunthorpe Message-ID: <0a605543-477a-1854-eb35-6e586606889b@deltatee.com> Date: Thu, 2 May 2019 21:14:08 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190501230126.229218-9-brendanhiggins@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 173.228.226.134 X-SA-Exim-Rcpt-To: wfg@linux.intel.com, rostedt@goodmis.org, rientjes@google.com, richard@nod.at, pmladek@suse.com, mpe@ellerman.id.au, knut.omang@oracle.com, khilman@baylibre.com, julia.lawall@lip6.fr, joel@jms.id.au, jdike@addtoit.com, daniel@ffwll.ch, dan.j.williams@intel.com, dan.carpenter@oracle.com, amir73il@gmail.com, Tim.Bird@sony.com, Alexander.Levin@microsoft.com, linux-um@lists.infradead.org, linux-nvdimm@lists.01.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, shuah@kernel.org, sboyd@kernel.org, robh@kernel.org, mcgrof@kernel.org, kieran.bingham@ideasonboard.com, keescook@google.com, gregkh@linuxfoundation.org, frowand.list@gmail.com, brendanhiggins@google.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH v2 08/17] kunit: test: add support for test abort X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-05-01 5:01 p.m., Brendan Higgins wrote: > +/* > + * struct kunit_try_catch - provides a generic way to run code which might fail. > + * @context: used to pass user data to the try and catch functions. > + * > + * kunit_try_catch provides a generic, architecture independent way to execute > + * an arbitrary function of type kunit_try_catch_func_t which may bail out by > + * calling kunit_try_catch_throw(). If kunit_try_catch_throw() is called, @try > + * is stopped at the site of invocation and @catch is catch is called. I found some of the C++ comparisons in this series a bit distasteful but wasn't going to say anything until I saw the try catch.... But looking into the implementation it's just a thread that can exit early which seems fine to me. Just a poor choice of name I guess... [snip] > +static void __noreturn kunit_abort(struct kunit *test) > +{ > + kunit_set_death_test(test, true); > + > + kunit_try_catch_throw(&test->try_catch); > + > + /* > + * Throw could not abort from test. > + * > + * XXX: we should never reach this line! As kunit_try_catch_throw is > + * marked __noreturn. > + */ > + WARN_ONCE(true, "Throw could not abort from test!\n"); > +} > + > int kunit_init_test(struct kunit *test, const char *name) > { > spin_lock_init(&test->lock); > @@ -77,6 +103,7 @@ int kunit_init_test(struct kunit *test, const char *name) > test->name = name; > test->vprintk = kunit_vprintk; > test->fail = kunit_fail; > + test->abort = kunit_abort; There are a number of these function pointers which seem to be pointless to me as you only ever set them to one function. Just call the function directly. As it is, it is an unnecessary indirection for someone reading the code. If and when you have multiple implementations of the function then add the pointer. Don't assume you're going to need it later on and add all this maintenance burden if you never use it.. [snip] > +void kunit_generic_try_catch_init(struct kunit_try_catch *try_catch) > +{ > + try_catch->run = kunit_generic_run_try_catch; > + try_catch->throw = kunit_generic_throw; > +} Same here. There's only one implementation of try_catch and I can't really see any sensible justification for another implementation. Even if there is, add the indirection when the second implementation is added. This isn't C++ and we don't need to make everything a "method". Thanks, Logan