Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4679670iob; Sun, 8 May 2022 21:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6CXUVKaDb/slhrDN0Cyn6BP7Lz+zqdY0irl9lJpEbblvXkOPNjd3XKh3bG6uXM2oXpaTz X-Received: by 2002:a05:6a02:206:b0:399:3c9:f465 with SMTP id bh6-20020a056a02020600b0039903c9f465mr12158654pgb.388.1652071472618; Sun, 08 May 2022 21:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652071472; cv=none; d=google.com; s=arc-20160816; b=y49l0xsrspS1sVXohTXVkY/ehuezkxmO2uIbObBtknrWY63W18cI0KU10NzKxmAKK7 fH96gVedz30oVsfF0YEHrF/5iIp35tGCud2Efpsd23eG486wTS3DImpQqc45r/ZByWN5 STaUzpgYj0t1XFIMzYASZKkp+iLoQNUoiiDtje0DVWV8j7Mz0u0ReTXdn2LWFhb8zyd+ gUIMbBYA6aAJ0e0ya+W7erhP1ydDZWKdeYiKrYkt8nCZEZH2ex0hIKkvBY2HOuvphcZ7 9kNKsmsHm4bi5g3PHNbW0Ox25j8XebqFLQuUqXnppfQPOmm6/mc69FwtCey678RVns+E Gz/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ry9pc6MqoCtl1ekYJrKGewz9be6CvlnKs3gu0up3hV0=; b=ym2Ur5jMbBGtvKaqTbANnRGzOoiN6GVS+fc1gaI6aaEK8441C0hRSt3s8fni2U3/zd WArz+TkLJLmilei0VHKPwJnnRNAVWyPfLlxX723SyTcMujVnLGyoQORsQ4PIbgK3q8vn 9LF6t2acQMEWe5BRQEwk+sITsYE2xgfcNNHMORPdaLXlDbdM3HiKFQ+uue4LcG3u9mKh esSh3ypg/dhpJC7f4blDCVM/BZyFdV5R3/0VFaDLsRl6Hs6HWXUmmkdH0AAEq3rV/mj/ QKhYPz2KsgXi9KXF6CUjUtWoHntYsuBESMeXTNV7Fgn+dMNtCTgD/ZWzaJ7q8orWt94Y SEVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OF1dtvrq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 19-20020a631553000000b003c15242c473si13200395pgv.412.2022.05.08.21.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OF1dtvrq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9E15612DEE2; Sun, 8 May 2022 21:42:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1445574AbiEGFa2 (ORCPT + 99 others); Sat, 7 May 2022 01:30:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1445546AbiEGF35 (ORCPT ); Sat, 7 May 2022 01:29:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F7968306; Fri, 6 May 2022 22:26:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 80A5CB80688; Sat, 7 May 2022 05:26:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E092EC385A5; Sat, 7 May 2022 05:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651901169; bh=nQe0p43j/Mw8whyp4ledlH+zcvMZWDU55dgzK2n5vvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OF1dtvrqgh7JV7TBLY6pybQPVbAGzqyyK0gC4hORuHRVXcGG/GFx3WtF0/Ws6vc85 HUcSlDjMLz+tkfcWz1rigww7UKkefowTZ6a62Y2GLkOV07IpJ048r7tF//37RsOO43 btltTV42NcWL8zQlbF0hOYuTPCQENZ9Npb6sH0vM6XA0hJAx+S1LLxIYnhat+90VOf OSPK9urQLUl2rXgrj68qsYnFMb+RFK7N9NA4oolCGaD+l02BJkUtKsnWC7hw0knKkY Al+Ua+bRCtx3ifvdHy6kAXhcGAZrTkGYtFxr+ZFoTXPTZWyJaH+ofzqKXYGzfkoZT+ 9qe3yxEvxkXew== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Daniel Latypov , Brendan Higgins , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Subject: [PATCH v6 04/23] kunit: take `kunit_assert` as `const` Date: Sat, 7 May 2022 07:24:02 +0200 Message-Id: <20220507052451.12890-5-ojeda@kernel.org> In-Reply-To: <20220507052451.12890-1-ojeda@kernel.org> References: <20220507052451.12890-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The `kunit_do_failed_assertion` function passes its `struct kunit_assert` argument to `kunit_fail`. This one, in turn, calls its `format` field passing the assert again as a `const` pointer. Therefore, the whole chain may be made `const`. Reviewed-by: Daniel Latypov Signed-off-by: Miguel Ojeda --- This is a prerequisite patch, independently submitted at: https://lore.kernel.org/lkml/20220502093625.GA23225@kernel.org/ include/kunit/test.h | 2 +- lib/kunit/test.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/kunit/test.h b/include/kunit/test.h index 00b9ff7783ab..2eff4f1beb42 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -774,7 +774,7 @@ void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...); void kunit_do_failed_assertion(struct kunit *test, const struct kunit_loc *loc, enum kunit_assert_type type, - struct kunit_assert *assert, + const struct kunit_assert *assert, const char *fmt, ...); #define KUNIT_ASSERTION(test, assert_type, pass, assert_class, INITIALIZER, fmt, ...) do { \ diff --git a/lib/kunit/test.c b/lib/kunit/test.c index 3bca3bf5c15b..b84aed09a009 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -241,7 +241,7 @@ static void kunit_print_string_stream(struct kunit *test, } static void kunit_fail(struct kunit *test, const struct kunit_loc *loc, - enum kunit_assert_type type, struct kunit_assert *assert, + enum kunit_assert_type type, const struct kunit_assert *assert, const struct va_format *message) { struct string_stream *stream; @@ -281,7 +281,7 @@ static void __noreturn kunit_abort(struct kunit *test) void kunit_do_failed_assertion(struct kunit *test, const struct kunit_loc *loc, enum kunit_assert_type type, - struct kunit_assert *assert, + const struct kunit_assert *assert, const char *fmt, ...) { va_list args; -- 2.35.3