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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 63AB9C433B4 for ; Thu, 13 May 2021 19:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 329FA61414 for ; Thu, 13 May 2021 19:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbhEMTdg (ORCPT ); Thu, 13 May 2021 15:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbhEMTd1 (ORCPT ); Thu, 13 May 2021 15:33:27 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A568CC061756 for ; Thu, 13 May 2021 12:32:16 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id w80-20020a25df530000b02904f953b5241bso8293284ybg.18 for ; Thu, 13 May 2021 12:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=D+yqagsGWp1tAEgFX6sPw/TG2ByjsEg/cBXbIsBFBzw=; b=acF3o6KZ7Tyz+LT12SrTKSIZrlw0ycariii/Eq+dzME0v1aWXdhZqJisp7vrxn0pti kpp3pmw8ZfnovUCedVziAil5BfAoDXtdMFN5yZLgXb937CBgaKYfv3eV4Pw7nPtcacXs I7DYhVambo3aXKKNer/UVQezcunTjbAEOEgMdFC9rLp2dDUmdW/mPjYdwco2TeBP1cMa 1Z1dSnZQ0ZTE9evtBew/VsOwz5aWQ3Yt6npE7Ax+eMxVIshkdZdU8T4M746Ra4vgZ1JB z7vKrXTWzXaw4+hlwESZGYv8/tdpdvJUeSwuLI+Y0lpTSk1VkCgkVpg2cBuSt7jVUMmg VkuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=D+yqagsGWp1tAEgFX6sPw/TG2ByjsEg/cBXbIsBFBzw=; b=rCIzWLOW+AUw9QtgnpSu7V5SAdeE7/MMKXbrXaPlx/uYrYT1RSy10Z7cfdmo6q4jZ2 IwPtFqFJGWeeDwlWwAfEmEOJaERGV8iznCYcWAMLROPGy8NrTiU9aKMOtN8FU1J/6jOE s38B+wphbSlPDsMdZlMktjStmoPFMeGUvg3y+mO94X48MK3YyEwE3Ov3JBr35mGVgnn8 CxfNJ79//xkrGjbuy57hGa5tKtM0mHm812BlwmIeHov5erM+/9YcMPxre0glWWiaklWJ TbvtAf6v5DXBzu5S0BgbJO61AuhHfMz7kha4krOMBRIg37Au/ojxP9I2EoiXgdoHkdAP rIcQ== X-Gm-Message-State: AOAM5328BPgNrRyn2Gdz/1k2Y6KG/OXian46AnaDetvS0AFyt43fOUG1 m7MYUnnXHwe0p0j4UjeziS4OZavB58FOzQ== X-Google-Smtp-Source: ABdhPJzVzXZ4dRIPlNqyg2GWzAfK71f2xZtVVQeWjKQhSv1/edmZUwWher+K4Qy5JxEL4kjMkTcsQxMUK7hoAQ== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:5f61:8ca4:879b:809e]) (user=davidgow job=sendgmr) by 2002:a25:4409:: with SMTP id r9mr44236161yba.401.1620934335869; Thu, 13 May 2021 12:32:15 -0700 (PDT) Date: Thu, 13 May 2021 12:31:55 -0700 Message-Id: <20210513193204.816681-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog Subject: [PATCH v2 01/10] kunit: Do not typecheck binary assertions From: David Gow To: Brendan Higgins , Daniel Latypov , Shuah Khan Cc: David Gow , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The use of typecheck() in KUNIT_EXPECT_EQ() and friends is causing more problems than I think it's worth. Things like enums need to have their values explicitly cast, and literals all need to be very precisely typed, else a large warning will be printed. While typechecking does have its uses, the additional overhead of having lots of needless casts -- combined with the awkward error messages which don't mention which types are involved -- makes tests less readable and more difficult to write. By removing the typecheck() call, the two arguments still need to be of compatible types, but don't need to be of exactly the same time, which seems a less confusing and more useful compromise. Signed-off-by: David Gow Reviewed-by: Daniel Latypov Reviewed-by: Brendan Higgins --- Changes since v1: https://lore.kernel.org/linux-kselftest/20210507050908.1008686-1-davidgow@google.com/ - Tidy up the patch description to note that a warning was being produced, not an error. - Add additional patches to remove many of the now unnecessary casts. include/kunit/test.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/kunit/test.h b/include/kunit/test.h index 49601c4b98b8..4c56ffcb7403 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -775,7 +775,6 @@ void kunit_do_assertion(struct kunit *test, do { \ typeof(left) __left = (left); \ typeof(right) __right = (right); \ - ((void)__typecheck(__left, __right)); \ \ KUNIT_ASSERTION(test, \ __left op __right, \ -- 2.31.1.751.gd2f1c929bd-goog