From patchwork Mon Feb 7 18:33:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737809 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D390C4332F for ; Mon, 7 Feb 2022 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234400AbiBGSgx (ORCPT ); Mon, 7 Feb 2022 13:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240780AbiBGSdN (ORCPT ); Mon, 7 Feb 2022 13:33:13 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8454C0401DF for ; Mon, 7 Feb 2022 10:33:12 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id a8so44677284ejc.8 for ; Mon, 07 Feb 2022 10:33:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=760cUhZxPNwETk5wV5EY2nvw4jOkyadVdKCIRfo19SI=; b=JyS9GZHnjT9bhoYUISD8JLhKUztSrq34E7LzMSEG+Fku+syoufX3e03dE7yrNoZbHa A1oG97ObiGt8mcyfXCRapvZiT7ZXfd5Zc0fGUwBwgQzHelrmGtN0Oje6Z4mFu4973Z/M rc4IEWwsZlXBbBubVfzLHMO6Yzblc/tLKJO7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=760cUhZxPNwETk5wV5EY2nvw4jOkyadVdKCIRfo19SI=; b=mXEnROKniaOOH2lNAAHYQe+WkLXRqbS6zIr3B/c/bheDGkP+rR28ND27rjIrA+4xII MGValtjSfaJ/dcXRSHw/skyewzYWR2Des4TDHilg8wb4sK6Y0kPiezseTeZyO1qBGaiI P14bL3Ku7ejOcs0VT6yhXQ38UPBmMcRDwkUCli7NjTvsN1s/Z+11KLVt4Yx2vZRBealM A5LhujeJequb0EYP5b1/LF3kANorhh0Z5z2HOXDfjXhlgXUVXDWNZOENIcnhikTHY5rl Rz1TN6S+5cbFWqadfczv39UR98SaQsIIiTc6idFo3XQaBNOTzgtYldzHasFVqu3whVzd qtnw== X-Gm-Message-State: AOAM531CMV98QTj98etnYOGWkSB6KFYYKnmsZsXDSH2GDf+G3c6F/rrA f4szEVE+irkt+dpMzxmi1skNkw== X-Google-Smtp-Source: ABdhPJzPwW4MN9dFpmeUEHuglwyLi2U4ixfmt41b+Do0yf9A75RFLPmmngIHe2tP9bljAVGBr/Bzhw== X-Received: by 2002:a17:907:1627:: with SMTP id hb39mr784326ejc.407.1644258791316; Mon, 07 Feb 2022 10:33:11 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:10 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 1/6] kunit: Introduce _NULL and _NOT_NULL macros Date: Mon, 7 Feb 2022 19:33:03 +0100 Message-Id: <20220207183308.1829495-1-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Today, when we want to check if a pointer is NULL and not ERR we have two options: EXPECT_TRUE(test, ptr == NULL); or EXPECT_PTR_NE(test, ptr, (struct mystruct *)NULL); Create a new set of macros that take care of NULL checks. Signed-off-by: Ricardo Ribalda --- include/kunit/test.h | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/include/kunit/test.h b/include/kunit/test.h index b26400731c02..a84bf065e64b 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -1395,6 +1395,51 @@ do { \ ##__VA_ARGS__) /** + * KUNIT_EXPECT_NULL() - Expects that @ptr is null. + * @test: The test context object. + * @ptr: an arbitrary pointer. + * + * Sets an expectation that the value that @ptr evaluates to is null. This is + * semantically equivalent to KUNIT_EXPECT_PTR_EQ(@test, NULL, ptr). + * See KUNIT_EXPECT_TRUE() for more information. + */ +#define KUNIT_EXPECT_NULL(test, ptr) \ + KUNIT_BINARY_PTR_EQ_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + (typeof(ptr))NULL, \ + ptr) + +#define KUNIT_EXPECT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + (typeof(ptr))NULL, \ + ptr, \ + fmt, \ + ##__VA_ARGS__) +/** + * KUNIT_EXPECT_NOT_NULL() - Expects that @ptr is not null. + * @test: The test context object. + * @ptr: an arbitrary pointer. + * + * Sets an expectation that the value that @ptr evaluates to is not null. This + * is semantically equivalent to KUNIT_EXPECT_PTR_NE(@test, NULL, ptr). + * See KUNIT_EXPECT_TRUE() for more information. + */ +#define KUNIT_EXPECT_NOT_NULL(test, ptr) \ + KUNIT_BINARY_PTR_NE_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + (typeof(ptr))NULL, \ + ptr) + +#define KUNIT_EXPECT_NOT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + (typeof(ptr))NULL, \ + ptr, \ + fmt, \ + ##__VA_ARGS__) + + /** * KUNIT_EXPECT_NE() - An expectation that @left and @right are not equal. * @test: The test context object. * @left: an arbitrary expression that evaluates to a primitive C type. @@ -1678,6 +1723,52 @@ do { \ fmt, \ ##__VA_ARGS__) +/** + * KUNIT_ASSERT_NULL() - Asserts that pointers @ptr is null. + * @test: The test context object. + * @ptr: an arbitrary pointer. + * + * Sets an assertion that the values that @ptr evaluates to is null. This is + * the same as KUNIT_EXPECT_NULL(), except it causes an assertion + * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met. + */ +#define KUNIT_ASSERT_NULL(test, ptr) \ + KUNIT_BINARY_PTR_EQ_ASSERTION(test, \ + KUNIT_ASSERTION, \ + (typeof(ptr))NULL, \ + ptr) + +#define KUNIT_ASSERT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_EQ_MSG_ASSERTION(test, \ + KUNIT_ASSERTION, \ + (typeof(ptr))NULL, \ + ptr, \ + fmt, \ + ##__VA_ARGS__) + +/** + * KUNIT_ASSERT_NOT_NULL() - Asserts that pointers @ptr is not null. + * @test: The test context object. + * @ptr: an arbitrary pointer. + * + * Sets an assertion that the values that @ptr evaluates to is not null. This + * is the same as KUNIT_EXPECT_NOT_NULL(), except it causes an assertion + * failure (see KUNIT_ASSERT_TRUE()) when the assertion is not met. + */ +#define KUNIT_ASSERT_NOT_NULL(test, ptr) \ + KUNIT_BINARY_PTR_NE_ASSERTION(test, \ + KUNIT_ASSERTION, \ + (typeof(ptr))NULL, \ + ptr) + +#define KUNIT_ASSERT_NOT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_NE_MSG_ASSERTION(test, \ + KUNIT_ASSERTION, \ + (typeof(ptr))NULL, \ + ptr, \ + fmt, \ + ##__VA_ARGS__) + /** * KUNIT_ASSERT_NE() - An assertion that @left and @right are not equal. * @test: The test context object. From patchwork Mon Feb 7 18:33:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DE0EC433F5 for ; Mon, 7 Feb 2022 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbiBGSgv (ORCPT ); Mon, 7 Feb 2022 13:36:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240892AbiBGSdP (ORCPT ); Mon, 7 Feb 2022 13:33:15 -0500 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E401C0401DA for ; Mon, 7 Feb 2022 10:33:13 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id b13so32042736edn.0 for ; Mon, 07 Feb 2022 10:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UOdNmlyNPW+E8PGbp+vyT82pH5RDo7o+AEX7jRKD5jw=; b=nuQVGnnezF9lg6nibg/2aXIKCMQ3W/68d/aO0iVBTpGYcyDju/Y0kkZeGRcQvzznjk sScbVS+BMc4XFGFMfwBVV6y9SB++yayfvY4IPq2r04pMbDVVQs3CTYFV213uFkLMT50B cmg/aKBMlD/kQX5flEWMAMrMZI89aMLMANpyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UOdNmlyNPW+E8PGbp+vyT82pH5RDo7o+AEX7jRKD5jw=; b=MnRyqDIAZgPfuX0h95hkE9JXvRjrg5WSDvLKshCzO7gYEK7HPXx5h8bPoCiwKMwxiH TqMMgffYHygXU1WajMiBIIXsVcbQwuv8D3sEOtS1jPr7FrdSoxMs+2ai+jdqZERgDLpL Q4FQguyQFlfDc7NqNe5hpgQ7x6XTwVuAvZ8JmLDGziKPtWj56yAXsATYzn4wXeo227nB OH6slzmfBqwyw7pmLCbhEMS/9PrZ8iKVHuHy0m4UNdVArjf9AYuFE+RZEqmPweYqhu+m CogbHQyP5XX3BodmB7YKH2KoKWbC9n4NpVKjcFurHbe3/ZGfhrfsjClzxfDrwpPr/hYr TyRQ== X-Gm-Message-State: AOAM530kyAxeINKBNLdfrbbVh4PoyUyJkQtAezthSk3tSNyoVb8pyZQG dPqWMpCJK2oLWf4riFVnuDl7aQ== X-Google-Smtp-Source: ABdhPJzR6ZCXSzDStxms2BYUniX+sUMJLVUk7k/mfssjFejB8kAPP1SgM/X5vvVAqe/qUS4PPvo0Rw== X-Received: by 2002:a05:6402:50c8:: with SMTP id h8mr802268edb.144.1644258791896; Mon, 07 Feb 2022 10:33:11 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:11 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 2/6] thunderbolt: test: use NULL macros Date: Mon, 7 Feb 2022 19:33:04 +0100 Message-Id: <20220207183308.1829495-2-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220207183308.1829495-1-ribalda@chromium.org> References: <20220207183308.1829495-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Replace the NULL checks with the more specific and idiomatic NULL macros. Signed-off-by: Ricardo Ribalda --- drivers/thunderbolt/test.c | 130 ++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c index 1f69bab236ee..b8c9dc7cc02f 100644 --- a/drivers/thunderbolt/test.c +++ b/drivers/thunderbolt/test.c @@ -796,9 +796,9 @@ static void tb_test_path_not_connected(struct kunit *test) up = &dev2->ports[9]; path = tb_path_alloc(NULL, down, 8, up, 8, 0, "PCIe Down"); - KUNIT_ASSERT_TRUE(test, path == NULL); + KUNIT_ASSERT_NULL(test, path); path = tb_path_alloc(NULL, down, 8, up, 8, 1, "PCIe Down"); - KUNIT_ASSERT_TRUE(test, path == NULL); + KUNIT_ASSERT_NULL(test, path); } struct hop_expectation { @@ -847,7 +847,7 @@ static void tb_test_path_not_bonded_lane0(struct kunit *test) up = &dev->ports[9]; path = tb_path_alloc(NULL, down, 8, up, 8, 0, "PCIe Down"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -909,7 +909,7 @@ static void tb_test_path_not_bonded_lane1(struct kunit *test) out = &dev->ports[13]; path = tb_path_alloc(NULL, in, 9, out, 9, 1, "Video"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -989,7 +989,7 @@ static void tb_test_path_not_bonded_lane1_chain(struct kunit *test) out = &dev3->ports[13]; path = tb_path_alloc(NULL, in, 9, out, 9, 1, "Video"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -1069,7 +1069,7 @@ static void tb_test_path_not_bonded_lane1_chain_reverse(struct kunit *test) out = &host->ports[5]; path = tb_path_alloc(NULL, in, 9, out, 9, 1, "Video"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -1161,7 +1161,7 @@ static void tb_test_path_mixed_chain(struct kunit *test) out = &dev4->ports[13]; path = tb_path_alloc(NULL, in, 9, out, 9, 1, "Video"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -1253,7 +1253,7 @@ static void tb_test_path_mixed_chain_reverse(struct kunit *test) out = &host->ports[5]; path = tb_path_alloc(NULL, in, 9, out, 9, 1, "Video"); - KUNIT_ASSERT_TRUE(test, path != NULL); + KUNIT_ASSERT_NOT_NULL(test, path); KUNIT_ASSERT_EQ(test, path->path_length, ARRAY_SIZE(test_data)); for (i = 0; i < ARRAY_SIZE(test_data); i++) { const struct tb_port *in_port, *out_port; @@ -1297,7 +1297,7 @@ static void tb_test_tunnel_pcie(struct kunit *test) down = &host->ports[8]; up = &dev1->ports[9]; tunnel1 = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel1); KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_PCI); KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); @@ -1312,7 +1312,7 @@ static void tb_test_tunnel_pcie(struct kunit *test) down = &dev1->ports[10]; up = &dev2->ports[9]; tunnel2 = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel2); KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_PCI); KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); @@ -1349,7 +1349,7 @@ static void tb_test_tunnel_dp(struct kunit *test) out = &dev->ports[13]; tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); @@ -1395,7 +1395,7 @@ static void tb_test_tunnel_dp_chain(struct kunit *test) out = &dev4->ports[14]; tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); @@ -1445,7 +1445,7 @@ static void tb_test_tunnel_dp_tree(struct kunit *test) out = &dev5->ports[13]; tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); @@ -1510,7 +1510,7 @@ static void tb_test_tunnel_dp_max_length(struct kunit *test) out = &dev12->ports[13]; tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DP); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, in); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, out); @@ -1566,7 +1566,7 @@ static void tb_test_tunnel_usb3(struct kunit *test) down = &host->ports[12]; up = &dev1->ports[16]; tunnel1 = tb_tunnel_alloc_usb3(NULL, up, down, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel1); KUNIT_EXPECT_EQ(test, tunnel1->type, TB_TUNNEL_USB3); KUNIT_EXPECT_PTR_EQ(test, tunnel1->src_port, down); KUNIT_EXPECT_PTR_EQ(test, tunnel1->dst_port, up); @@ -1581,7 +1581,7 @@ static void tb_test_tunnel_usb3(struct kunit *test) down = &dev1->ports[17]; up = &dev2->ports[16]; tunnel2 = tb_tunnel_alloc_usb3(NULL, up, down, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel2); KUNIT_EXPECT_EQ(test, tunnel2->type, TB_TUNNEL_USB3); KUNIT_EXPECT_PTR_EQ(test, tunnel2->src_port, down); KUNIT_EXPECT_PTR_EQ(test, tunnel2->dst_port, up); @@ -1628,7 +1628,7 @@ static void tb_test_tunnel_port_on_path(struct kunit *test) out = &dev5->ports[13]; dp_tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, dp_tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, dp_tunnel); KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, in)); KUNIT_EXPECT_TRUE(test, tb_tunnel_port_on_path(dp_tunnel, out)); @@ -1685,7 +1685,7 @@ static void tb_test_tunnel_dma(struct kunit *test) port = &host->ports[1]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 8, 1, 8, 1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); @@ -1728,7 +1728,7 @@ static void tb_test_tunnel_dma_rx(struct kunit *test) port = &host->ports[1]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, -1, -1, 15, 2); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); @@ -1765,7 +1765,7 @@ static void tb_test_tunnel_dma_tx(struct kunit *test) port = &host->ports[1]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 15, 2, -1, -1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); @@ -1811,7 +1811,7 @@ static void tb_test_tunnel_dma_chain(struct kunit *test) nhi = &host->ports[7]; port = &dev2->ports[3]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 8, 1, 8, 1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_EXPECT_EQ(test, tunnel->type, TB_TUNNEL_DMA); KUNIT_EXPECT_PTR_EQ(test, tunnel->src_port, nhi); KUNIT_EXPECT_PTR_EQ(test, tunnel->dst_port, port); @@ -1857,7 +1857,7 @@ static void tb_test_tunnel_dma_match(struct kunit *test) port = &host->ports[1]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 15, 1, 15, 1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, 15, 1)); KUNIT_ASSERT_FALSE(test, tb_tunnel_match_dma(tunnel, 8, 1, 15, 1)); @@ -1873,7 +1873,7 @@ static void tb_test_tunnel_dma_match(struct kunit *test) tb_tunnel_free(tunnel); tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 15, 1, -1, -1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, 1, -1, -1)); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, 15, -1, -1, -1)); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, 1, -1, -1)); @@ -1885,7 +1885,7 @@ static void tb_test_tunnel_dma_match(struct kunit *test) tb_tunnel_free(tunnel); tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, -1, -1, 15, 11); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, 11)); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, 15, -1)); KUNIT_ASSERT_TRUE(test, tb_tunnel_match_dma(tunnel, -1, -1, -1, 11)); @@ -1910,7 +1910,7 @@ static void tb_test_credit_alloc_legacy_not_bonded(struct kunit *test) down = &host->ports[8]; up = &dev->ports[9]; tunnel = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); path = tunnel->paths[0]; @@ -1943,7 +1943,7 @@ static void tb_test_credit_alloc_legacy_bonded(struct kunit *test) down = &host->ports[8]; up = &dev->ports[9]; tunnel = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); path = tunnel->paths[0]; @@ -1976,7 +1976,7 @@ static void tb_test_credit_alloc_pcie(struct kunit *test) down = &host->ports[8]; up = &dev->ports[9]; tunnel = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); path = tunnel->paths[0]; @@ -2010,7 +2010,7 @@ static void tb_test_credit_alloc_dp(struct kunit *test) out = &dev->ports[14]; tunnel = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)3); /* Video (main) path */ @@ -2053,7 +2053,7 @@ static void tb_test_credit_alloc_usb3(struct kunit *test) down = &host->ports[12]; up = &dev->ports[16]; tunnel = tb_tunnel_alloc_usb3(NULL, up, down, 0, 0); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); path = tunnel->paths[0]; @@ -2087,7 +2087,7 @@ static void tb_test_credit_alloc_dma(struct kunit *test) port = &dev->ports[3]; tunnel = tb_tunnel_alloc_dma(NULL, nhi, port, 8, 1, 8, 1); - KUNIT_ASSERT_TRUE(test, tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel); KUNIT_ASSERT_EQ(test, tunnel->npaths, (size_t)2); /* DMA RX */ @@ -2141,7 +2141,7 @@ static void tb_test_credit_alloc_dma_multiple(struct kunit *test) * remaining 1 and then we run out of buffers. */ tunnel1 = tb_tunnel_alloc_dma(NULL, nhi, port, 8, 1, 8, 1); - KUNIT_ASSERT_TRUE(test, tunnel1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel1); KUNIT_ASSERT_EQ(test, tunnel1->npaths, (size_t)2); path = tunnel1->paths[0]; @@ -2159,7 +2159,7 @@ static void tb_test_credit_alloc_dma_multiple(struct kunit *test) KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 14U); tunnel2 = tb_tunnel_alloc_dma(NULL, nhi, port, 9, 2, 9, 2); - KUNIT_ASSERT_TRUE(test, tunnel2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel2); KUNIT_ASSERT_EQ(test, tunnel2->npaths, (size_t)2); path = tunnel2->paths[0]; @@ -2177,7 +2177,7 @@ static void tb_test_credit_alloc_dma_multiple(struct kunit *test) KUNIT_EXPECT_EQ(test, path->hops[1].initial_credits, 1U); tunnel3 = tb_tunnel_alloc_dma(NULL, nhi, port, 10, 3, 10, 3); - KUNIT_ASSERT_TRUE(test, tunnel3 == NULL); + KUNIT_ASSERT_NULL(test, tunnel3); /* * Release the first DMA tunnel. That should make 14 buffers @@ -2186,7 +2186,7 @@ static void tb_test_credit_alloc_dma_multiple(struct kunit *test) tb_tunnel_free(tunnel1); tunnel3 = tb_tunnel_alloc_dma(NULL, nhi, port, 10, 3, 10, 3); - KUNIT_ASSERT_TRUE(test, tunnel3 != NULL); + KUNIT_ASSERT_NOT_NULL(test, tunnel3); path = tunnel3->paths[0]; KUNIT_ASSERT_EQ(test, path->path_length, 2); @@ -2216,7 +2216,7 @@ static struct tb_tunnel *TB_TEST_PCIE_TUNNEL(struct kunit *test, down = &host->ports[8]; up = &dev->ports[9]; pcie_tunnel = tb_tunnel_alloc_pci(NULL, up, down); - KUNIT_ASSERT_TRUE(test, pcie_tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, pcie_tunnel); KUNIT_ASSERT_EQ(test, pcie_tunnel->npaths, (size_t)2); path = pcie_tunnel->paths[0]; @@ -2246,7 +2246,7 @@ static struct tb_tunnel *TB_TEST_DP_TUNNEL1(struct kunit *test, in = &host->ports[5]; out = &dev->ports[13]; dp_tunnel1 = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, dp_tunnel1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, dp_tunnel1); KUNIT_ASSERT_EQ(test, dp_tunnel1->npaths, (size_t)3); path = dp_tunnel1->paths[0]; @@ -2283,7 +2283,7 @@ static struct tb_tunnel *TB_TEST_DP_TUNNEL2(struct kunit *test, in = &host->ports[6]; out = &dev->ports[14]; dp_tunnel2 = tb_tunnel_alloc_dp(NULL, in, out, 0, 0); - KUNIT_ASSERT_TRUE(test, dp_tunnel2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, dp_tunnel2); KUNIT_ASSERT_EQ(test, dp_tunnel2->npaths, (size_t)3); path = dp_tunnel2->paths[0]; @@ -2320,7 +2320,7 @@ static struct tb_tunnel *TB_TEST_USB3_TUNNEL(struct kunit *test, down = &host->ports[12]; up = &dev->ports[16]; usb3_tunnel = tb_tunnel_alloc_usb3(NULL, up, down, 0, 0); - KUNIT_ASSERT_TRUE(test, usb3_tunnel != NULL); + KUNIT_ASSERT_NOT_NULL(test, usb3_tunnel); KUNIT_ASSERT_EQ(test, usb3_tunnel->npaths, (size_t)2); path = usb3_tunnel->paths[0]; @@ -2350,7 +2350,7 @@ static struct tb_tunnel *TB_TEST_DMA_TUNNEL1(struct kunit *test, nhi = &host->ports[7]; port = &dev->ports[3]; dma_tunnel1 = tb_tunnel_alloc_dma(NULL, nhi, port, 8, 1, 8, 1); - KUNIT_ASSERT_TRUE(test, dma_tunnel1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, dma_tunnel1); KUNIT_ASSERT_EQ(test, dma_tunnel1->npaths, (size_t)2); path = dma_tunnel1->paths[0]; @@ -2380,7 +2380,7 @@ static struct tb_tunnel *TB_TEST_DMA_TUNNEL2(struct kunit *test, nhi = &host->ports[7]; port = &dev->ports[3]; dma_tunnel2 = tb_tunnel_alloc_dma(NULL, nhi, port, 9, 2, 9, 2); - KUNIT_ASSERT_TRUE(test, dma_tunnel2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, dma_tunnel2); KUNIT_ASSERT_EQ(test, dma_tunnel2->npaths, (size_t)2); path = dma_tunnel2->paths[0]; @@ -2496,50 +2496,50 @@ static void tb_test_property_parse(struct kunit *test) struct tb_property *p; dir = tb_property_parse_dir(root_directory, ARRAY_SIZE(root_directory)); - KUNIT_ASSERT_TRUE(test, dir != NULL); + KUNIT_ASSERT_NOT_NULL(test, dir); p = tb_property_find(dir, "foo", TB_PROPERTY_TYPE_TEXT); KUNIT_ASSERT_TRUE(test, !p); p = tb_property_find(dir, "vendorid", TB_PROPERTY_TYPE_TEXT); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_STREQ(test, p->value.text, "Apple Inc."); p = tb_property_find(dir, "vendorid", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa27); p = tb_property_find(dir, "deviceid", TB_PROPERTY_TYPE_TEXT); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_STREQ(test, p->value.text, "Macintosh"); p = tb_property_find(dir, "deviceid", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0xa); p = tb_property_find(dir, "missing", TB_PROPERTY_TYPE_DIRECTORY); KUNIT_ASSERT_TRUE(test, !p); p = tb_property_find(dir, "network", TB_PROPERTY_TYPE_DIRECTORY); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); network_dir = p->value.dir; KUNIT_EXPECT_TRUE(test, uuid_equal(network_dir->uuid, &network_dir_uuid)); p = tb_property_find(network_dir, "prtcid", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); p = tb_property_find(network_dir, "prtcvers", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); p = tb_property_find(network_dir, "prtcrevs", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0x1); p = tb_property_find(network_dir, "prtcstns", TB_PROPERTY_TYPE_VALUE); - KUNIT_ASSERT_TRUE(test, p != NULL); + KUNIT_ASSERT_NOT_NULL(test, p); KUNIT_EXPECT_EQ(test, p->value.immediate, 0x0); p = tb_property_find(network_dir, "deviceid", TB_PROPERTY_TYPE_VALUE); @@ -2558,7 +2558,7 @@ static void tb_test_property_format(struct kunit *test) int ret, i; dir = tb_property_parse_dir(root_directory, ARRAY_SIZE(root_directory)); - KUNIT_ASSERT_TRUE(test, dir != NULL); + KUNIT_ASSERT_NOT_NULL(test, dir); ret = tb_property_format_dir(dir, NULL, 0); KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); @@ -2566,7 +2566,7 @@ static void tb_test_property_format(struct kunit *test) block_len = ret; block = kunit_kzalloc(test, block_len * sizeof(u32), GFP_KERNEL); - KUNIT_ASSERT_TRUE(test, block != NULL); + KUNIT_ASSERT_NOT_NULL(test, block); ret = tb_property_format_dir(dir, block, block_len); KUNIT_EXPECT_EQ(test, ret, 0); @@ -2584,10 +2584,10 @@ static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, int n1, n2, i; if (d1->uuid) { - KUNIT_ASSERT_TRUE(test, d2->uuid != NULL); + KUNIT_ASSERT_NOT_NULL(test, d2->uuid); KUNIT_ASSERT_TRUE(test, uuid_equal(d1->uuid, d2->uuid)); } else { - KUNIT_ASSERT_TRUE(test, d2->uuid == NULL); + KUNIT_ASSERT_NOT_NULL(test, d2->uuid); } n1 = 0; @@ -2606,9 +2606,9 @@ static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, p2 = NULL; for (i = 0; i < n1; i++) { p1 = tb_property_get_next(d1, p1); - KUNIT_ASSERT_TRUE(test, p1 != NULL); + KUNIT_ASSERT_NOT_NULL(test, p1); p2 = tb_property_get_next(d2, p2); - KUNIT_ASSERT_TRUE(test, p2 != NULL); + KUNIT_ASSERT_NOT_NULL(test, p2); KUNIT_ASSERT_STREQ(test, &p1->key[0], &p2->key[0]); KUNIT_ASSERT_EQ(test, p1->type, p2->type); @@ -2616,14 +2616,14 @@ static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, switch (p1->type) { case TB_PROPERTY_TYPE_DIRECTORY: - KUNIT_ASSERT_TRUE(test, p1->value.dir != NULL); - KUNIT_ASSERT_TRUE(test, p2->value.dir != NULL); + KUNIT_ASSERT_NOT_NULL(test, p1->value.dir); + KUNIT_ASSERT_NOT_NULL(test, p2->value.dir); compare_dirs(test, p1->value.dir, p2->value.dir); break; case TB_PROPERTY_TYPE_DATA: - KUNIT_ASSERT_TRUE(test, p1->value.data != NULL); - KUNIT_ASSERT_TRUE(test, p2->value.data != NULL); + KUNIT_ASSERT_NOT_NULL(test, p1->value.data); + KUNIT_ASSERT_NOT_NULL(test, p2->value.data); KUNIT_ASSERT_TRUE(test, !memcmp(p1->value.data, p2->value.data, p1->length * 4) @@ -2631,8 +2631,8 @@ static void compare_dirs(struct kunit *test, struct tb_property_dir *d1, break; case TB_PROPERTY_TYPE_TEXT: - KUNIT_ASSERT_TRUE(test, p1->value.text != NULL); - KUNIT_ASSERT_TRUE(test, p2->value.text != NULL); + KUNIT_ASSERT_NOT_NULL(test, p1->value.text); + KUNIT_ASSERT_NOT_NULL(test, p2->value.text); KUNIT_ASSERT_STREQ(test, p1->value.text, p2->value.text); break; @@ -2654,10 +2654,10 @@ static void tb_test_property_copy(struct kunit *test) int ret, i; src = tb_property_parse_dir(root_directory, ARRAY_SIZE(root_directory)); - KUNIT_ASSERT_TRUE(test, src != NULL); + KUNIT_ASSERT_NOT_NULL(test, src); dst = tb_property_copy_dir(src); - KUNIT_ASSERT_TRUE(test, dst != NULL); + KUNIT_ASSERT_NOT_NULL(test, dst); /* Compare the structures */ compare_dirs(test, src, dst); @@ -2667,7 +2667,7 @@ static void tb_test_property_copy(struct kunit *test) KUNIT_ASSERT_EQ(test, ret, ARRAY_SIZE(root_directory)); block = kunit_kzalloc(test, sizeof(root_directory), GFP_KERNEL); - KUNIT_ASSERT_TRUE(test, block != NULL); + KUNIT_ASSERT_NOT_NULL(test, block); ret = tb_property_format_dir(dst, block, ARRAY_SIZE(root_directory)); KUNIT_EXPECT_TRUE(test, !ret); From patchwork Mon Feb 7 18:33:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737808 X-Patchwork-Delegate: brendanhiggins@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BD4AC43217 for ; Mon, 7 Feb 2022 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233896AbiBGSgw (ORCPT ); Mon, 7 Feb 2022 13:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240853AbiBGSdO (ORCPT ); Mon, 7 Feb 2022 13:33:14 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12778C0401D9 for ; Mon, 7 Feb 2022 10:33:14 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id cn6so9361420edb.5 for ; Mon, 07 Feb 2022 10:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ssHaNiY3LReYl3MVuJ+ePd9JHdf9OG1Dd7zZJ3nge2k=; b=Y04HjLPsZkYdoFCeBvut+f8CXidNVJOGkPxikLhixK501IvyPyXIzekoWjSlmrF8OX u03ERTnhW8DE58bhyNSXTsd2whnjJBZ4aIpR0gDNddM7XqB+9jop/3FmKpHHKtBg7Lc+ Cf23LyG18ool9UQz6QmgP8iyLNerW26JbfoaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ssHaNiY3LReYl3MVuJ+ePd9JHdf9OG1Dd7zZJ3nge2k=; b=Y4rAOdiGROBcs7Mpiv+hhUx+8t2CE6oqItXYCeBgO34zVBt8vAUKHSTHk+V/AsGb35 7V69OWbgmqvJk/4TN3z+CDJY0P6wKEBGvejLqxUTTbP/aQXd5cq2ceazqM44rgau0WGm qO/QqVl7+eMBvZGwrhA6AaF1bKFPAb0KeDW+N+laSzBBT+6EH1KhOPcYrnwkpKBOXWk4 4w2w/8KYvKbkXDdLS6OM+Mf9t7GKjm8Jy8ZQmI2f3a5/Lh8HhMGy9gIeq4YH+81GnuAq gvesAiSwmbsIgKtS2/Z7Nvx3ag9yRldj5Jp+M6ejX1pN15PWihof/YYAlfN0ZVAePzgT 5Vhg== X-Gm-Message-State: AOAM532U+HAL16NTGl87LjLDlvQDvWdOjOloFyfmDbtSlLKbgj7fU7LA 3TTfhIXe0e6RWZgAjbFKQdo1Xw== X-Google-Smtp-Source: ABdhPJwGN4VbnI4x7rDYfog/zY+635S5wcdgEYYlW6+Pp2dJwVNzXbvi5aUiiztSLaMEBlh2B8XjcQ== X-Received: by 2002:aa7:c043:: with SMTP id k3mr790601edo.184.1644258792671; Mon, 07 Feb 2022 10:33:12 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:12 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 3/6] kunit: use NULL macros Date: Mon, 7 Feb 2022 19:33:05 +0100 Message-Id: <20220207183308.1829495-3-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220207183308.1829495-1-ribalda@chromium.org> References: <20220207183308.1829495-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Replace the NULL checks with the more specific and idiomatic NULL macros. Signed-off-by: Ricardo Ribalda --- lib/kunit/kunit-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c index 555601d17f79..8e2fe083a549 100644 --- a/lib/kunit/kunit-test.c +++ b/lib/kunit/kunit-test.c @@ -435,7 +435,7 @@ static void kunit_log_test(struct kunit *test) KUNIT_EXPECT_NOT_ERR_OR_NULL(test, strstr(suite.log, "along with this.")); #else - KUNIT_EXPECT_PTR_EQ(test, test->log, (char *)NULL); + KUNIT_EXPECT_NULL(test, test->log); #endif } From patchwork Mon Feb 7 18:33:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737810 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B803C4321E for ; Mon, 7 Feb 2022 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233817AbiBGSgw (ORCPT ); Mon, 7 Feb 2022 13:36:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240875AbiBGSdP (ORCPT ); Mon, 7 Feb 2022 13:33:15 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A671EC0401DF for ; Mon, 7 Feb 2022 10:33:14 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id p15so44721579ejc.7 for ; Mon, 07 Feb 2022 10:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=elxmE3zs5g2Y4x1nlwNY1X/XBfQO0VsIOMiC0QvhdRs=; b=ib7OInvnGb1390rQvsxx41sBLDlYlnymqB0W0z5ewFkH7jX1eD7AhbpgqSMOyBYVpB DLEad2S0PIUl8kXzhHS/oLN5pUStvOM0WPsxQeQHfedN29gpnGMXXeoh384vDq6//n2G RyjMwFGldPpDN29Jg+T3JflHK6vN4HiODJMbc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=elxmE3zs5g2Y4x1nlwNY1X/XBfQO0VsIOMiC0QvhdRs=; b=ofLzYhSr/1IMmomboPphGzM0Tpu3504o26IZeOdH73mKGiTD5E/mVrODUMYN3zmBaP j4cd4HYgGCt2UE0cSH0Xl8xRpXBqS+de6SWxKLiD0KPyRTFlt3KvozVt8HFdSMXQHJN7 quxbmMWoXGv6TwXqA4jR+5y2hs0fEZcZ1JPxzXWKsiWtEzVpXZ+Aw4LOulUDriJdEwTa 9nr+rK3SHq+AMI5uBXRdbzEA5dJmSEp4HZZdzyzgSP5ziAxuigozjFihvX5Y+2QkjDOt ZaIOJ5kVNvyj1sEoXp/WXnnWC3uhYE4lmS9t7uZg15734xuj4tx0/265x6v02cfUa3ka Yv2A== X-Gm-Message-State: AOAM533hD6vhXttOu/5M/pDFnprhcTf059Z+Tp/VVIbfU0R2Hc6mjaed CaKIgdUBi7dFvPdSRgvKF7s/BQ== X-Google-Smtp-Source: ABdhPJx2znfkJdWuVEfTJQm+QwhAab9EmEa5PLUcvF/yiqLO7zPWj6QRIx5XFn0ngzxpPzD5Fv6lpA== X-Received: by 2002:a17:906:9756:: with SMTP id o22mr807187ejy.448.1644258793323; Mon, 07 Feb 2022 10:33:13 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:13 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 4/6] kasan: test: Use NULL macros Date: Mon, 7 Feb 2022 19:33:06 +0100 Message-Id: <20220207183308.1829495-4-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220207183308.1829495-1-ribalda@chromium.org> References: <20220207183308.1829495-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Replace PTR_EQ checks with the more idiomatic and specific NULL macros. Signed-off-by: Ricardo Ribalda --- lib/test_kasan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index 26a5c9007653..ae15f7bf7313 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -385,7 +385,7 @@ static void krealloc_uaf(struct kunit *test) kfree(ptr1); KUNIT_EXPECT_KASAN_FAIL(test, ptr2 = krealloc(ptr1, size2, GFP_KERNEL)); - KUNIT_ASSERT_PTR_EQ(test, (void *)ptr2, NULL); + KUNIT_ASSERT_NULL(test, ptr2); KUNIT_EXPECT_KASAN_FAIL(test, *(volatile char *)ptr1); } From patchwork Mon Feb 7 18:33:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C82AC433FE for ; Mon, 7 Feb 2022 18:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233985AbiBGSgx (ORCPT ); Mon, 7 Feb 2022 13:36:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240906AbiBGSdP (ORCPT ); Mon, 7 Feb 2022 13:33:15 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36816C0401D9 for ; Mon, 7 Feb 2022 10:33:15 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id eg42so16291799edb.7 for ; Mon, 07 Feb 2022 10:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=COoBb1joui25djaKHvMRbQv4Mt4Thb8VpuVozeRERCg=; b=LEDvpjbLxdkIAECgUtmhd0Pewx1MCYa0vTxWBQ5qOvlF9mxSP9MgL2WPumTTF76XQd rs/FWbPD/12K4cKHrCp40Q/xDzWkqd6ZohMpK2WRtXfeE7ZHVZFzkm38chEZFaLfZ+rG TuagRfezFAf5P9Iahh9BeHasERZJQdCttHLnc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=COoBb1joui25djaKHvMRbQv4Mt4Thb8VpuVozeRERCg=; b=3SgdITlnVZ8jDeYFwU38nDht0XqjaqZIXbIKGQ8go/HAZVs/deu2570ZHApHXYI4JD LsMjGTZPLr6ATKBJiP1+QgOOpcaEMizlHz805p7nAZv+mAohxRg+I4ro8aXA1WoVbdNW PuLKCtKsh9jVUEKDPvufC0YJvosDVW9iTVFRm28e/WCRdYTzPMcuQTJxHHoAwIws4LB1 E9+2wsGLEz8Kap/NpYxeH+ogISk90LxUuaTTAF8AivmrIakRjv+Zm6rTBBEtOQ61+FQ2 4+UbI6VQxs0Y9W9jIzhSxHv/b8wYhM3n+wlGaczaObRCA23Fko6TzIEzIiCMCiXGLNqW OvEQ== X-Gm-Message-State: AOAM532VDcA6S1qJoa9XoHKYq3YlVx3O3q5ehSNjLonx0Bu4Pq7nHuBv 0S9Tr//vOMnFiNiL/Y6NNBYo5A== X-Google-Smtp-Source: ABdhPJyYpPuIcCeeyxuf5tTwSyQd8EC7oNpXtyv9AK75BOvAZ9VzgGG58uhyr6gisCzTKM431Calhg== X-Received: by 2002:a05:6402:2789:: with SMTP id b9mr784253ede.308.1644258793829; Mon, 07 Feb 2022 10:33:13 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:13 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 5/6] mctp: test: Use NULL macros Date: Mon, 7 Feb 2022 19:33:07 +0100 Message-Id: <20220207183308.1829495-5-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220207183308.1829495-1-ribalda@chromium.org> References: <20220207183308.1829495-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Replace the PTR_EQ NULL checks wit the NULL macros. More idiomatic and specific. Signed-off-by: Ricardo Ribalda --- net/mctp/test/route-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mctp/test/route-test.c b/net/mctp/test/route-test.c index 750f9f9b4daf..eb70b524c78e 100644 --- a/net/mctp/test/route-test.c +++ b/net/mctp/test/route-test.c @@ -361,7 +361,7 @@ static void mctp_test_route_input_sk(struct kunit *test) } else { KUNIT_EXPECT_NE(test, rc, 0); skb2 = skb_recv_datagram(sock->sk, 0, 1, &rc); - KUNIT_EXPECT_PTR_EQ(test, skb2, NULL); + KUNIT_EXPECT_NULL(test, skb2); } __mctp_route_test_fini(test, dev, rt, sock); @@ -430,7 +430,7 @@ static void mctp_test_route_input_sk_reasm(struct kunit *test) skb_free_datagram(sock->sk, skb2); } else { - KUNIT_EXPECT_PTR_EQ(test, skb2, NULL); + KUNIT_EXPECT_NULL(test, skb2); } __mctp_route_test_fini(test, dev, rt, sock); From patchwork Mon Feb 7 18:33:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 12737806 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16EAFC433FE for ; Mon, 7 Feb 2022 18:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbiBGSgh (ORCPT ); Mon, 7 Feb 2022 13:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240926AbiBGSdQ (ORCPT ); Mon, 7 Feb 2022 13:33:16 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9E4FC0401DA for ; Mon, 7 Feb 2022 10:33:15 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id p15so44721756ejc.7 for ; Mon, 07 Feb 2022 10:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sQV3FF5mFgBVe7Tg/aDZitfy1ByGgWInZOonbxaNvNg=; b=l4qyatFZhyECRncPLcXL8VNkiMsmHadTVF8MBX9JntJrammN4JstK81tY9P8n6tvcL oGNyxh/lnCKWL1BNREH/G58qnyJ5uCKz+A19Az6Cz0BOiU6rL4qieFp6j0dME2DnFeXI fsaJdue9hmuH/oaqIUx4D/z+WsOVdJzhZPq0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sQV3FF5mFgBVe7Tg/aDZitfy1ByGgWInZOonbxaNvNg=; b=5Q29GIg/dDWqrOof45R9qOylFs8ZWkXvlgP2IRd78s1+TXN57k+Wp8NH14BmvF5j6+ /5N+hrPO29nG0AwsWdTMAI+9SmXbEVQ0r+mdVxkKgw7oaJ1WXMJzaCGEVqI2t97LxL2F Fd2dfmh1hbsFYrxFxyXtj9WJmrkgL0Se+dGhUi4bA04WvTyksocb7+GrEzUfxB9B3Q5j LvBcEek70Sh/Pw7lf8h0DKnp0bCjGshz2rBdcCZKDlds73rig2q50Imdd2NpxCoqY+ON pCOA7qiq8XxGlofDOsO9A6/z1dRJtRHBWcm/mY71sjx6aANGZIfQS9MvCNfbA5Aekwat QUkQ== X-Gm-Message-State: AOAM530ZCE4mcY7x+q8Iqm+LiHtFmqqoVvRwpD7TgYlNiJLc92MqUQ9S ZTmLv6UQLqiskNkMNEu32WgF8A== X-Google-Smtp-Source: ABdhPJzPyU4JY8Gr4F6U8ZniBFYs/FdtbhAwY6umKjMplE4ASnx4SFwbOXTYMvegEjdUmC5ceiR7dQ== X-Received: by 2002:a17:906:5a5c:: with SMTP id my28mr775731ejc.54.1644258794460; Mon, 07 Feb 2022 10:33:14 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id k15sm3045173eji.64.2022.02.07.10.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:33:14 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg Cc: Ricardo Ribalda Subject: [PATCH 6/6] apparmor: test: Use NULL macros Date: Mon, 7 Feb 2022 19:33:08 +0100 Message-Id: <20220207183308.1829495-6-ribalda@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220207183308.1829495-1-ribalda@chromium.org> References: <20220207183308.1829495-1-ribalda@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Replace the PTR_EQ NULL checks with the more idiomatic and specific NULL macros. Signed-off-by: Ricardo Ribalda --- security/apparmor/policy_unpack_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/apparmor/policy_unpack_test.c b/security/apparmor/policy_unpack_test.c index 533137f45361..5c18d2f19862 100644 --- a/security/apparmor/policy_unpack_test.c +++ b/security/apparmor/policy_unpack_test.c @@ -313,7 +313,7 @@ static void policy_unpack_test_unpack_strdup_out_of_bounds(struct kunit *test) size = unpack_strdup(puf->e, &string, TEST_STRING_NAME); KUNIT_EXPECT_EQ(test, size, 0); - KUNIT_EXPECT_PTR_EQ(test, string, (char *)NULL); + KUNIT_EXPECT_NULL(test, string); KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, start); } @@ -409,7 +409,7 @@ static void policy_unpack_test_unpack_u16_chunk_out_of_bounds_1( size = unpack_u16_chunk(puf->e, &chunk); KUNIT_EXPECT_EQ(test, size, (size_t)0); - KUNIT_EXPECT_PTR_EQ(test, chunk, (char *)NULL); + KUNIT_EXPECT_NULL(test, chunk); KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->end - 1); } @@ -431,7 +431,7 @@ static void policy_unpack_test_unpack_u16_chunk_out_of_bounds_2( size = unpack_u16_chunk(puf->e, &chunk); KUNIT_EXPECT_EQ(test, size, (size_t)0); - KUNIT_EXPECT_PTR_EQ(test, chunk, (char *)NULL); + KUNIT_EXPECT_NULL(test, chunk); KUNIT_EXPECT_PTR_EQ(test, puf->e->pos, puf->e->start + TEST_U16_OFFSET); }