Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp226448iob; Mon, 2 May 2022 17:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySm3SlV00+Fov0naqoDS7Yt9n9yZdxq30HanHDNwL1zQv0zyeFaW2h1A145tGSQClR5R4j X-Received: by 2002:a05:6a00:c8c:b0:50e:eea:1a0 with SMTP id a12-20020a056a000c8c00b0050e0eea01a0mr579739pfv.66.1651538909710; Mon, 02 May 2022 17:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651538909; cv=none; d=google.com; s=arc-20160816; b=sSPk68ts/8z+dbpNe32xrEE/AGtl55cEJzYPryMTqK16JMIvE+aFJTogXTa5wG6DRA eUyzcMPLUwOnlvOiUsOGX0piXG4z2npUVw34gjcU6FzFtxsLdGS4wknDTDPj/j50pzm/ UE5a5AHDDwUiL9dKPY/BOmiXLx46alfyvTro5Kw5sehqRiMIIN+38T0CBscE+0ze47nu 8C51tz0483XGyC9pSEq3035LgwNFSAD/bibgM14EoxQStMg+KswLrF+RbOeDS76gy1Dn cLlK6YKlfqS9/1tsdHImi9J9g4lRkKGJpI+avPPsKlVs3VUtwAa7EtUkteSPLES8xyUJ cSHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=RDYGIANRTtTxWiWR1qrl5uCtfaktf4IaR+hFbMAPoPE=; b=CS6wA8AYXl9Rx74NC9Xx/9p/5tUFxhskJ3+D4K7q5gCp3DpohBl8T7QV7XkToMzuWQ S65iJBIeaLmM2gT1iyWQxiwmV7ckpyGtx/Gpx5jV13Y55F5GwwvVD0XZ75HkQ6prgdJN LD8mUrIVOXv8eausu5LUBwD3RVZYGllKwP2wkEFAjilJGmmYY1euXnymDbHPprRJTiW0 Ww8J6hihAuvMr6d7beSJAdmBdTfKbZxNGkc1S5vrkAlS4Xnb4BeeLna3JsmQ3/dz4xQx /MvnlU0lRAVKG7hxhEOEeYjVjbvVBgbzp6o7tNJG/aNhGU6JFu7zxYMD0dTtcspJQEoY 6dmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oUxQcaHM; 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 q190-20020a6343c7000000b0039db2bfc365si15302983pga.161.2022.05.02.17.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:48:29 -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=oUxQcaHM; 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 5B3BF3ED32; Mon, 2 May 2022 17:37:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384240AbiEBJkW (ORCPT + 99 others); Mon, 2 May 2022 05:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384262AbiEBJkT (ORCPT ); Mon, 2 May 2022 05:40:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C241645AF0; Mon, 2 May 2022 02:36:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 5E2CA611D6; Mon, 2 May 2022 09:36:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDDF1C385AC; Mon, 2 May 2022 09:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651484208; bh=9BAQqLLOLL2trD6C1GTCsmN5pgx0ztTic3hcYSWhX9A=; h=Date:From:To:Cc:Subject:From; b=oUxQcaHM94xydxjvrkgSw7NmKshl+4h5S4T5rb4cqqPnvNZKwuu5M2wMUBPZ47qTk 3saZe7V6J5rhz5bzxG1j/TiorgbmXoq0b5oDsBcU/DL5EP3wntWBaaA4KovkksdWza 7pUZVAvYBX/QCF2yXj/P3LEmzeg34mTDIf3H7fxKDELdw3aPpypuufSM4Es7rzKM7f llRT6M7wmTM5DFie+q/JrZEcn3bykvPHWpdV7DgTViKBRaEYp/UngYXtmi5SzOmAfq TGwKui26HxsYysoDnsFGpo8OfOK1Ye5RcZagalecH6Zm9vD7Yp31BFYHYNRawVaStF 9pyiErpIANLqg== Date: Mon, 2 May 2022 11:36:25 +0200 From: Miguel Ojeda To: Brendan Higgins Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] kunit: take `kunit_assert` as `const` Message-ID: <20220502093625.GA23225@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: elm/2 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`. Signed-off-by: Miguel Ojeda --- 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