From nobody Sun Apr 19 10:44:03 2026 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 663D4CCA47F for ; Sun, 3 Jul 2022 21:17:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbiGCVRF (ORCPT ); Sun, 3 Jul 2022 17:17:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiGCVRE (ORCPT ); Sun, 3 Jul 2022 17:17:04 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28F895F95; Sun, 3 Jul 2022 14:17:03 -0700 (PDT) Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4LbhZq3XlCzDqb8; Sun, 3 Jul 2022 21:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1656883022; bh=6Ij8yOwB4JYb9RD/LraY+fNrTpkLeOaMfQgUySj3D08=; h=From:To:Cc:Subject:Date:From; b=pOCVJ59irxatorE7DrR6wHRNx9/P0MC49Tu6buujPr0C2Y8+YJE1ro2FFYlcO4qeB TXrjz5LfZA2pOd99El2qHB63Hpl1FxB5wg9DIdw7NpRpQ7Wbaq1TKk0WcCSAZu2Alf dqKvLW7ihcPqKf2rzpLUV0atgrPCTdMCNhZg1YpA= X-Riseup-User-ID: A375FB2AA550E8B726569AC28C478E255E83A99C7E458BD264E12F57DEAE1F4D Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4LbhZm3jhjz5vTK; Sun, 3 Jul 2022 21:16:48 +0000 (UTC) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Brendan Higgins , Jonathan Corbet , davidgow@google.com Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH v2] Documentation: KUnit: Fix example with compilation error Date: Sun, 3 Jul 2022 18:16:42 -0300 Message-Id: <20220703211642.550255-1-mairacanal@riseup.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Parameterized Testing example contains a compilation error, as the signature for the description helper function is void(*)(const struct sha1_test_case *, char *), and the struct is non-const. This is warned by Clang: error: initialization of =E2=80=98void (*)(struct sha1_test_case *, char *)= =E2=80=99 from incompatible pointer type =E2=80=98void (*)(const struct sha1_test_cas= e *, char *)=E2=80=99 [-Werror=3Dincompatible-pointer-types] 33 | KUNIT_ARRAY_PARAM(sha1, cases, case_to_desc); | ^~~~~~~~~~~~ ../include/kunit/test.h:1339:70: note: in definition of macro =E2=80=98KUNIT_ARRAY_PARAM=E2=80=99 1339 | void (*__get_desc)(typeof(__next), char *) =3D get_desc; \ Signed-off-by: Ma=C3=ADra Canal --- v1 -> v2: https://lore.kernel.org/linux-kselftest/CABVgOSkFKJBNt-AsWmOh2Oni= 4QO2xdiXJiYD1EVcS-Qz=3DBjJRw@mail.gmail.com/T/#mf546fc75bf9e5bd27cb3bbd531b= 51409fbc87a9d - Instead of changing the function signature to non-const, makes the cases const (David Gow). --- Documentation/dev-tools/kunit/usage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-to= ols/kunit/usage.rst index d62a04255c2e..44158eecb51e 100644 --- a/Documentation/dev-tools/kunit/usage.rst +++ b/Documentation/dev-tools/kunit/usage.rst @@ -505,7 +505,7 @@ By reusing the same ``cases`` array from above, we can = write the test as a const char *str; const char *sha1; }; - struct sha1_test_case cases[] =3D { + const struct sha1_test_case cases[] =3D { { .str =3D "hello world", .sha1 =3D "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed", --=20 2.36.1