Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp158224pxy; Thu, 6 May 2021 23:38:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxhwCGHg5iWDlHIUpV9WT8VbdvRmn2tOUayuUTVPhz33Q/F0RgC2Fx99hm/Rc3uynBCdxi X-Received: by 2002:a17:907:1ca8:: with SMTP id nb40mr8306478ejc.181.1620369521775; Thu, 06 May 2021 23:38:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620369521; cv=none; d=google.com; s=arc-20160816; b=S0Fi9YLgDL89KbWyjjIH14qNXokiyGYNAvxUh7OoIaluw5fOYaR1cwLhj7FammZnNX jppedhDjO90Hqm6fNU7FDTIJxc+Y2S4+wb6gEuRaLcmH7pck7Fwx/pnybCdos3C4KHhg eLiMHNsDznCp1IAD7OmUDB1tSTDnDQDMDqmjYMEB8RDqUm/+3MPx+IpBqszbcT0qEaYW gtshXkawQyJHOQdTNZ9RdVM0hbP7y5lK5hjTgQC3ZkwuR2bgh9DUUQtxwPRARMivl+Ju euYnu9GxyxpzUS23iQE+TC+i4qL2zY5v9ccF1Upf1vVdieaZnBNQQMb1ZdqCdRkJMvwp IUmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=jSTI64CJ1fjEq5OTPDv3eN3+6glJnRm4XHS+PKPJDqQ=; b=zujgUPiKxeUJhJUUEZfZfN8ItTjGOQ20mSlJfE3KQitO9J/ydzPNzt8Nc3uk2mPWH9 BBtpb4n1Ug/iealC8pwgnDpUFFwOLA4WXWio00P4t5CACkh6B9eFlEFEaLFha+9FZVSU nq4E3K8wMQ9h6ZZwk0nXkVnUxVlcZA/kcdNSXLsGVKopZEYXcBzQEwcUcu8efoDzB7jD JXSjSzXxPdx4jAkpTLxzzKOpVNUVst+dQpyau8s3jbhxqJSno9mjKJGNA3ocyW72wkSO cYwRfYIMhN/B0AbmU5iETGyRgbPmTwm2XDb5LZrDxmahDy9bk93lk1Jj/zrYTZzpAqS1 ZYfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JVIXRhcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx5si4452579ejc.393.2021.05.06.23.38.17; Thu, 06 May 2021 23:38:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JVIXRhcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbhEGFKX (ORCPT + 99 others); Fri, 7 May 2021 01:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbhEGFKW (ORCPT ); Fri, 7 May 2021 01:10:22 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0D4C061761 for ; Thu, 6 May 2021 22:09:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id v12-20020a25848c0000b02904f30b36aebfso8826152ybk.1 for ; Thu, 06 May 2021 22:09:20 -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=jSTI64CJ1fjEq5OTPDv3eN3+6glJnRm4XHS+PKPJDqQ=; b=JVIXRhcjz7NCzpFAcvQ+vpKLDHmL3+gV0tpn3h+3lYDO6SgFnmFaCx5Aa8B8YGhYQL XYbXHEpkJ2BastYVJE5UxO5ocwv+ghKnd6Y5sO6OcjMzAwRGdkvZ19A7NCWJyHTnzsR5 7Muwz5cO+4J0doAO4LKM/W6Pkd31Emd19Kj/TIINVihz7ASMCUo55GwyPWFxEG1TL9Ce DXUxq49XNginaHoHcdFrIMxf8LpSO5TbrSuE9Lnjg28YgClK98Q5V/RYkK0W5jl4tWMX Gp+iw9aBR6SZ35PZLiB7tQlwhPLPR5NSVZfed9scnvw81usR4vm1G8RZGcBoGeubfzOj WRDA== 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=jSTI64CJ1fjEq5OTPDv3eN3+6glJnRm4XHS+PKPJDqQ=; b=bN7Gv9bOPz+4HtT+EzrfjgO0pQ2e2SCr3MHjNhTDXfRg2GqbdTd2qF+ZsnbtrVdh/n CQkAYaZm1/XQV0A1A/nPkWbPVsXpnHRCqLDoqlhXU5Ep5EAlibOTqedvbMYaASoEpSZ7 IkbvojjuqyIioL3qR4oREzdahn7n2aFVVv/3W9khhJhJnQkBlFD+UOjZKWOcDi4igHvd ZLZ+uUrk56FITDP6EXtH8kUBit9XhAltdVcgw8QCmccvXHdej9Iy5mnFKaFAUSqvJhz2 dfhc6/37yLIjfF9DsIO5Sk2rZ3WC+B4NuC0nwBiF5Ghx7AkJiEqHzxRCbyKn/4We5P9o +OmA== X-Gm-Message-State: AOAM533vO8v/V54dsa11Y85968DLF0vtobavkAs9wPz5VU6TKuRhL2y8 xUBKp+HJFJZWuxOUYat7LnsgI9oH0c0usA== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:7a7f:ce22:a6af:49e5]) (user=davidgow job=sendgmr) by 2002:a25:cacd:: with SMTP id a196mr11407255ybg.296.1620364159507; Thu, 06 May 2021 22:09:19 -0700 (PDT) Date: Thu, 6 May 2021 22:09:07 -0700 Message-Id: <20210507050908.1008686-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH 1/2] 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 for the code to compile. 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 --- I appreciate that this is probably a bit controversial (and, indeed, I was a bit hesitant about sending it out myself), but after sitting on it for a few days, I still think this is probably an improvement overall. The second patch does fix what I think is an actual bug, though, so even if this isn't determined to be a good idea, it (or some equivalent) should probably go through. Cheers, -- David 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.607.g51e8a6a459-goog