From patchwork Fri Feb 11 16:42:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 542260 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 36BD7C433EF for ; Fri, 11 Feb 2022 16:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239487AbiBKQmw (ORCPT ); Fri, 11 Feb 2022 11:42:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232139AbiBKQmw (ORCPT ); Fri, 11 Feb 2022 11:42:52 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05A83D4B for ; Fri, 11 Feb 2022 08:42:50 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id bx2so17313785edb.11 for ; Fri, 11 Feb 2022 08:42:49 -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=vsf2QgtdatJ2wExDY4gvcboSixkFghVOFaraVlgt+kM=; b=IuNoXsuKuLx9Go7T1AUl+TlgxLY5HcQtoU/BmcZQG8etPFFcIv2WATpIJM99eWsnVu G8k1QoDaKXsX8Ym3SQXc2ry2fEteera0sP60Ker8mc/N8RPmvX+UZ53A/5CnBuT9yk1s NQqGmuFdbEmnyZ6PX8DwG8CxmnDt7WGhDaYeU= 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=vsf2QgtdatJ2wExDY4gvcboSixkFghVOFaraVlgt+kM=; b=JsIKSk+TqnUwCmgycmrOq0h2l+y3zCkt6UyFxWnRnxsqHtvuGCdIDfNaHh4/y7vj/m WPEBZkdjE2p6cyfiIM/tgvIVipcPdwywZFJ+UVgDJ+6pMzWZChYDHwAaklbrf97jyh+K 6Lbgv/I1HbnIH0iQoKuRzOEbyE6Ki/fbXHyUVHTV/zqqjShLr5yrL8uQeIW6Z7cdVslm +bJE8Z5sb8aoBRzajDVOAN/ffbjqfXL7N4OBPwHvkf8DFP2FmwX12bGhXFnz0hVn4TPP gVnFd9axhqKkzkjlXro+1Atrh4ad+V/gGGz+IbNWS2qLxYWPxx8tE3jP1kNstniUYZzp s4uA== X-Gm-Message-State: AOAM532s2GJNblSRChr1ga3i7o0MhF5Y7epYfgMMp25sclfqdh+Lz7qb d93lCv7QnhrHacFWkqNszeEQyQ== X-Google-Smtp-Source: ABdhPJyTmStlxOsX6f+36mZG/NIl9+NRGvVff6pOo8ngLlNAgbMvBk4gc3jzU7voGCy3NzYEPUC3Ag== X-Received: by 2002:a05:6402:3608:: with SMTP id el8mr2759937edb.193.1644597768422; Fri, 11 Feb 2022 08:42:48 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:48 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 1/6] kunit: Introduce _NULL and _NOT_NULL macros Date: Fri, 11 Feb 2022 17:42:41 +0100 Message-Id: <20220211164246.410079-1-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-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: KUNIT_EXPECT_TRUE(test, ptr == NULL); or KUNIT_EXPECT_PTR_NE(test, ptr, (struct mystruct *)NULL); Create a new set of macros that take care of NULL checks. Reviewed-by: Brendan Higgins Reviewed-by: Daniel Latypov Signed-off-by: Ricardo Ribalda --- include/kunit/test.h | 84 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/include/kunit/test.h b/include/kunit/test.h index 00b9ff7783ab..e6c18b609b47 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -1218,6 +1218,48 @@ do { \ fmt, \ ##__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, ptr, NULL). + * See KUNIT_EXPECT_TRUE() for more information. + */ +#define KUNIT_EXPECT_NULL(test, ptr) \ + KUNIT_EXPECT_NULL_MSG(test, \ + ptr, \ + NULL) + +#define KUNIT_EXPECT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + ptr, ==, NULL, \ + 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, ptr, NULL). + * See KUNIT_EXPECT_TRUE() for more information. + */ +#define KUNIT_EXPECT_NOT_NULL(test, ptr) \ + KUNIT_EXPECT_NOT_NULL_MSG(test, \ + ptr, \ + NULL) + +#define KUNIT_EXPECT_NOT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_ASSERTION(test, \ + KUNIT_EXPECTATION, \ + ptr, !=, NULL, \ + fmt, \ + ##__VA_ARGS__) + /** * KUNIT_EXPECT_NOT_ERR_OR_NULL() - Expects that @ptr is not null and not err. * @test: The test context object. @@ -1485,6 +1527,48 @@ 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_ASSERT_NULL_MSG(test, \ + ptr, \ + NULL) + +#define KUNIT_ASSERT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_ASSERTION(test, \ + KUNIT_ASSERTION, \ + ptr, ==, NULL, \ + 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_ASSERT_NOT_NULL_MSG(test, \ + ptr, \ + NULL) + +#define KUNIT_ASSERT_NOT_NULL_MSG(test, ptr, fmt, ...) \ + KUNIT_BINARY_PTR_ASSERTION(test, \ + KUNIT_ASSERTION, \ + ptr, !=, NULL, \ + fmt, \ + ##__VA_ARGS__) + /** * KUNIT_ASSERT_NOT_ERR_OR_NULL() - Assertion that @ptr is not null and not err. * @test: The test context object. From patchwork Fri Feb 11 16:42:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 541952 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 B33D6C433FE for ; Fri, 11 Feb 2022 16:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbiBKQmw (ORCPT ); Fri, 11 Feb 2022 11:42:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239618AbiBKQmw (ORCPT ); Fri, 11 Feb 2022 11:42:52 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78452D65 for ; Fri, 11 Feb 2022 08:42:50 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id bx2so17313822edb.11 for ; Fri, 11 Feb 2022 08:42:50 -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=Ne9bnxO4PK4jt9C/gSl+PDTM3EheSheXGE0rb10tDic=; b=eJVH8qawyVTBLCSWPWiGRU0BRG5bChJSOS86AFKUmAwQP28wio8kX3AvbIQDYMxGea OpbC9YsZnavJCmJUFvHxPjia5MQ9L/V0DtN0HmsiBRuZ2tb6gRODPFKa4HpZSobNW1DK hpa97d+1DkBz3ze/babCdiw+mYbKLMRt8Kij4= 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=Ne9bnxO4PK4jt9C/gSl+PDTM3EheSheXGE0rb10tDic=; b=VNOfgwT5KbS+HWOq+SgRwE9ubdRxyz4LRMvOGN0aZm4MaLRncICcq/KWvA3EpZk2U9 6T5cFaIyYpYktmRhFF07zHsIm0arW/nwMrV1nyAd6UlCiL3HY/+XS8SYzUEr8ai2YKn6 XJROVIr/UkLN1ObZOCFKumyXQA4CPxjfPbv/fCeytOmwC6RiDN0Gy/H74gOV3aJbfiJK Ra1fU1ysIa9xLT8p05Pl/+1by2auhlH3KUzsMKsmyxMtMa1eu3bruvY98EtgJW8f+ymY eLs0jrfpNpSEKl28pQp0TI+tO3KRK1KvPHyIZCDz90+FQ0PoPgBt6kTZrWBTyVB38I9E XCZw== X-Gm-Message-State: AOAM532H1EStN8YTvcUIUih6rgBY6+KLVTwNEpj4NWt37WZvzu+PDTRE h4HDzFNmS5hhAbw+fNduxAwI1w== X-Google-Smtp-Source: ABdhPJyEK70H5tG8606Z//huqYZksMdOT+gUfcDtP7gw9as16sSq0mkvRiF4OyU4XyFil4PXQBV5WQ== X-Received: by 2002:a05:6402:34c7:: with SMTP id w7mr2808333edc.397.1644597769058; Fri, 11 Feb 2022 08:42:49 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:48 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 2/6] kunit: use NULL macros Date: Fri, 11 Feb 2022 17:42:42 +0100 Message-Id: <20220211164246.410079-2-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220211164246.410079-1-ribalda@chromium.org> References: <20220211164246.410079-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. Reviewed-by: Brendan Higgins Reviewed-by: Daniel Latypov Signed-off-by: Ricardo Ribalda --- lib/kunit/kunit-example-test.c | 2 ++ lib/kunit/kunit-test.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/kunit/kunit-example-test.c b/lib/kunit/kunit-example-test.c index 4bbf37c04eba..91b1df7f59ed 100644 --- a/lib/kunit/kunit-example-test.c +++ b/lib/kunit/kunit-example-test.c @@ -91,6 +91,8 @@ static void example_all_expect_macros_test(struct kunit *test) KUNIT_EXPECT_NOT_ERR_OR_NULL(test, test); KUNIT_EXPECT_PTR_EQ(test, NULL, NULL); KUNIT_EXPECT_PTR_NE(test, test, NULL); + KUNIT_EXPECT_NULL(test, NULL); + KUNIT_EXPECT_NOT_NULL(test, test); /* String assertions */ KUNIT_EXPECT_STREQ(test, "hi", "hi"); 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 Fri Feb 11 16:42:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 541951 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 A4E28C433F5 for ; Fri, 11 Feb 2022 16:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239618AbiBKQmy (ORCPT ); Fri, 11 Feb 2022 11:42:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345874AbiBKQmx (ORCPT ); Fri, 11 Feb 2022 11:42:53 -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 5C908D67 for ; Fri, 11 Feb 2022 08:42:51 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id fy20so23964900ejc.0 for ; Fri, 11 Feb 2022 08:42:51 -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=IVHDPnjThumdH+1Kg81/BwK2S0Mx1gscE8qAw7/EuOA=; b=KMfviZ8QEU+GA0zHqtFtKXJk4ww6WMNUAZg77b+LXWwGwuoMNmym7R9muFwcpUalVQ bwRECGYU0DmqnZ83xTsrRiy62sxIl+OIK1MI5MU1ovufpqCebTXBnZ13fi96eFu6IST4 QonikK53O+ztXlVWCNb23Xb9QyN/CSI0Xj6vQ= 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=IVHDPnjThumdH+1Kg81/BwK2S0Mx1gscE8qAw7/EuOA=; b=hNZK9Nj/E4XziW/DFPp79vN92oa49KGQFZP7doH4sXd5B9gwzwlD2fflRrL1mhgwva PmF04P+v9MRiHXWLz8J9p+sJpdutfuiNFLL1nAkM0PHVfTQ2XlsziFHLEvxV3bbHEWu7 TrRPEGEQDb5/75VCILfg7tk51mbPyIoj9aHqBZZGG+Qn1i78g9nbi23pkHkkqviM/yf1 8lIQPUFva8KqQF9s2tQ1Cj8f73TJcvEi0itfu7rihVXAoJog9VneQ3jETwAcFkm8HeiC SNnfF9HOqa9/pldLHzk8N6e9QfvdAdIn8xED/3mXuvq5wnnuwzkToxFoiAW2qHeH8j7/ QCTQ== X-Gm-Message-State: AOAM533643g08nPMl98iMvhmDaiO/Taz6Naz9lcdmZ/ea1hLnisbkg5j Kdw1gqwlpkdZ9d5nHdaBWVGa2IvX7TjYl6j8 X-Google-Smtp-Source: ABdhPJwDkHOmMgCJv0fU+JoiQiCZu7vWUxXAsioJdg6o0ZJMzfNfxT6+PkYTlYE/G24DULNT+HMSeQ== X-Received: by 2002:a17:907:9620:: with SMTP id gb32mr2138820ejc.546.1644597769719; Fri, 11 Feb 2022 08:42:49 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:49 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 3/6] thunderbolt: test: use NULL macros Date: Fri, 11 Feb 2022 17:42:43 +0100 Message-Id: <20220211164246.410079-3-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220211164246.410079-1-ribalda@chromium.org> References: <20220211164246.410079-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. Acked-by: Mika Westerberg Acked-by: Daniel Latypov Signed-off-by: Ricardo Ribalda Acked-by: Brendan Higgins --- drivers/thunderbolt/test.c | 134 ++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/drivers/thunderbolt/test.c b/drivers/thunderbolt/test.c index 1f69bab236ee..be9b1d7e63d2 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); + KUNIT_ASSERT_NULL(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); + KUNIT_ASSERT_NULL(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_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 Fri Feb 11 16:42:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 542259 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 467B0C4332F for ; Fri, 11 Feb 2022 16:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351624AbiBKQmy (ORCPT ); Fri, 11 Feb 2022 11:42:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239618AbiBKQmx (ORCPT ); Fri, 11 Feb 2022 11:42:53 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B20F5D4B for ; Fri, 11 Feb 2022 08:42:51 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id g7so1338030edb.5 for ; Fri, 11 Feb 2022 08:42:51 -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=Yxy7zthPRWHub+MPiGJfuPkSoZH4U5JEJa8lsfSBR/o=; b=lzPfOcHoLZ/MvAabpJ9+1KHNRqERbZ9ViET9utyITXE8KWzeHk5oIeKmMoB0JCzXfm WjE738yEIaQBcJf2AdwEHYaNko+xo3KTQX+r7maDKtXmDkD6QPcFYY0SwRFn/cudLoI9 mkLC68XUZMQo7Qb/T9lbpOdTqnq5/3NAtONZY= 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=Yxy7zthPRWHub+MPiGJfuPkSoZH4U5JEJa8lsfSBR/o=; b=XVlEff5xtQPJxyTfYLGvKyztQ63Q8ITw2Ap7Cxbj7rtaQELC8+49LcH+FI4Wa9A8P4 +wxUZmdJ4P4dgfxvsMNuiE72QHCDatEPvSUvkNdEBRGFmhAxP7EyNy3lG/tsM+0bnBRt D/KnhQS/ALBL9RA1uabMoH/uh9kc4ylXm7uZJd0+ohrZYKhSht57L9O++F9z2P1PG37T LXFRYbazJ2oLbdl1b2gC08W84ritImf9CvkkxIAQ/ZYNOOLCubJNIy7aFjtspBZJvZre xyoVJRqqAtOWrw4wSuvnQjvp+sL9y0osdA8kPlJnAp6pdT/EkgIMJK0Ez3sZOiJ0rUac X3Uw== X-Gm-Message-State: AOAM530WyLUZzvfaAXlRRlKP1YmfG/5HpdUbLX7EUMjEKErGUYyejaII gJP5RTMojIVdvvs24oHh4U7Txvx82NOK26+N X-Google-Smtp-Source: ABdhPJzOjFHIjOptbXcHITdtxZD2BmaLRrRvZ5js16yJdezTSXuHMvUn/ik1AmIE0i9siNCsjTMHZA== X-Received: by 2002:a05:6402:27c9:: with SMTP id c9mr2876049ede.178.1644597770279; Fri, 11 Feb 2022 08:42:50 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:50 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 4/6] kasan: test: Use NULL macros Date: Fri, 11 Feb 2022 17:42:44 +0100 Message-Id: <20220211164246.410079-4-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220211164246.410079-1-ribalda@chromium.org> References: <20220211164246.410079-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. Acked-by: Daniel Latypov Signed-off-by: Ricardo Ribalda Acked-by: Brendan Higgins --- 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 847cdbefab46..d680f46740b8 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 Fri Feb 11 16:42:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 542258 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 BAE69C433EF for ; Fri, 11 Feb 2022 16:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345874AbiBKQmz (ORCPT ); Fri, 11 Feb 2022 11:42:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346048AbiBKQmy (ORCPT ); Fri, 11 Feb 2022 11:42:54 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E8CD65 for ; Fri, 11 Feb 2022 08:42:52 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id fy20so23964977ejc.0 for ; Fri, 11 Feb 2022 08:42:52 -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=rByTC1qdfOpqKBTw6wu+dL30l5MNIQcmECFcqJUWyKk=; b=Apm/1Dcq04AOQP1nf0sM50YTxPSNKPphcmBwPtpFYqyf48PIpexvySpft5eC4s5CQA ae+uVMZ8qnlg2VP1Y+JiUUO7VfCItetgHqc7crAJHon7uUOj8uMWTEFkDKnRch2Yb2lb 7Uoujn7i2r1YGrk5IHyCN2Ks955cOItQA4pyY= 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=rByTC1qdfOpqKBTw6wu+dL30l5MNIQcmECFcqJUWyKk=; b=79IUEGCP6ZHzvcNwcLHmx8YUHictEOXLw5HSPpp3q6TWlKZg+weY/j5Ml3BWSJJeIn jxruigDHF2vGrJr386s3DdqiBM2oAG7N0+b4/Y+tC7tEWcbWSWSXeFBN1l7oerBh4Uz7 MBCDRRfjq2k4apSUi8qIs58H9kwuxLssHPW0BNXr9UJF5aw03rLUQbezZ8zkQl3usj+e LizTCq4ErnquTSgNgkIj8P0JhXPdGb9jYvon6ku3GYxmWY8EzEbF8DsOAxyIMzdRU9ui IN9pYbLvB9MKQbcZ5plcoFCatcgNkmfBdZo+FdDjVcHFgmoINbY4dapuecpO4hMvcfLY bm1Q== X-Gm-Message-State: AOAM533Sw2JdZsaoqLK2HQ0nIR9ICOGXJ5hqM4LaPvn+FXHobEykHuGw ZwxgyZJVoBVj+x9cH168fHQB9f9EjYL0mG6O X-Google-Smtp-Source: ABdhPJyghpl0kmsPlbudSlrl9sXyxv6+Gp2dtQpTLg38O5ChSt/cIhmJazsho7PPlnjZmCPj5bWvwA== X-Received: by 2002:a17:907:6e14:: with SMTP id sd20mr2085294ejc.749.1644597770859; Fri, 11 Feb 2022 08:42:50 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:50 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 5/6] mctp: test: Use NULL macros Date: Fri, 11 Feb 2022 17:42:45 +0100 Message-Id: <20220211164246.410079-5-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220211164246.410079-1-ribalda@chromium.org> References: <20220211164246.410079-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. Acked-by: Daniel Latypov Signed-off-by: Ricardo Ribalda Acked-by: Brendan Higgins --- 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 Fri Feb 11 16:42:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 541950 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 AAAE8C433F5 for ; Fri, 11 Feb 2022 16:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351640AbiBKQmz (ORCPT ); Fri, 11 Feb 2022 11:42:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351632AbiBKQmy (ORCPT ); Fri, 11 Feb 2022 11:42:54 -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 CC624D68 for ; Fri, 11 Feb 2022 08:42:52 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id e7so20029149ejn.13 for ; Fri, 11 Feb 2022 08:42:52 -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=rYp/F1vbxbLivUF65w2maaWuA20v5CCQAIJDPT6o8JY=; b=CL6Jlbne1nQ4xOStNkTjKFGiu6eZkyt70Mcb0LWc0882nAZ7P7kd+jW4SmkAkdbSOi SK2lKsX8ECKyxCq1E/oi+ky7sq/74xwgWEug8LnHLiiTm/zDSY3u7V739zYQHq14qwu0 KRESuB29xjHnegmn33WD7l+FJH06sG7eTLfZM= 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=rYp/F1vbxbLivUF65w2maaWuA20v5CCQAIJDPT6o8JY=; b=JkVmEoBzRzoOJ9P12d/p69fSvBzmV2KQu7GCdSUbfGvSP9WvuQqtCjkBwV99je92oO TCwcselHbB5Ka5XpVchx5UgOwQFOtPWVJJ9Ze+c+JWTYiWFGhi+Qi9UdkLEKVtwh+ePX qN7TP09A0aa0D6wjTgF90O2e7lm8fg/0xPC8W2ZXg1K0+nesfWMMbeIoI8FUbMvE0CZK Kc1VXi31AjV0Q0JB5PEUOBDB2EgnhZsz/666RhLECUWkB22RMVI8rznccpgO3CMBkoS/ 6d1qVtbwGvrI/7QlYvAGM+fsjCWHaXSeqXPjUK1C9bFS8PpTVsvyVsQ3XzdmKwXxsXSr T9uQ== X-Gm-Message-State: AOAM532XqjWgpoYOVWNLyWSoXfMS/XMa8ZChZ/O0TGGBY+TvJO180c/j WvhVuh5bvXSX0HpcCrSBbRgiTQ== X-Google-Smtp-Source: ABdhPJygyJBMvsfog6wCOcGdFWEDQXX093IZi30k7s33kVrBINglEQvM2MGt+3IsIw8946097lp0cw== X-Received: by 2002:a17:907:6d1b:: with SMTP id sa27mr2076137ejc.166.1644597771403; Fri, 11 Feb 2022 08:42:51 -0800 (PST) Received: from alco.lan (80.71.134.83.ipv4.parknet.dk. [80.71.134.83]) by smtp.gmail.com with ESMTPSA id i24sm4981233edt.86.2022.02.11.08.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 08:42:51 -0800 (PST) From: Ricardo Ribalda To: kunit-dev@googlegroups.com, kasan-dev@googlegroups.com, linux-kselftest@vger.kernel.org, Brendan Higgins , Mika Westerberg , Daniel Latypov Cc: Ricardo Ribalda Subject: [PATCH v6 6/6] apparmor: test: Use NULL macros Date: Fri, 11 Feb 2022 17:42:46 +0100 Message-Id: <20220211164246.410079-6-ribalda@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog In-Reply-To: <20220211164246.410079-1-ribalda@chromium.org> References: <20220211164246.410079-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. Acked-by: Daniel Latypov Signed-off-by: Ricardo Ribalda Acked-by: Brendan Higgins --- 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); }