Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp242171iob; Mon, 2 May 2022 18:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzD2wR9Dh3hNvesxNNEt2kaO+NBWx+2i6xV4bZ8Oc/Ib4v779hfZENAr4+xrqDCXjvO/kV1 X-Received: by 2002:a65:6544:0:b0:3c1:afab:dba3 with SMTP id a4-20020a656544000000b003c1afabdba3mr11799823pgw.557.1651540560129; Mon, 02 May 2022 18:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651540560; cv=none; d=google.com; s=arc-20160816; b=PFeVSJ90osx6lLEIlgHGeEu0MogHu/u64+/Jmdh076lY+BemBUxFyrqqfNd8ee+nVO ul8JmXt0iyvpFZ/qAGrfHWb1B+FjmxTYzP4YeEyzCWvKabFU7NxTDt56n1nLXZYYtqbJ OV7bHqj653195gTKuygR9BA70xO9CbtX5JA7H6cgQCrM5ZxZ5yQrFJG4ZymuWQ3Gzbor MOIj9eOTTAb9uxLuD0OOnRS3ZpNMLKU49i6UDNDXMDTdF4NQ0Ez/Tnb3CJGeWrr0XtLy j7iax72I+fsYC25ZnMbbxsHbcDhm3MKQOqxuNsRNAjB2ZQhSRbhGKOmLCBlLMstxEs9z RE8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KDKVWt6i2JVgFk5hQ0cN9rigyvuCgGuIi+Y1yp/hEyU=; b=vqRoOWURtvvx6YGiT/sCDkvKAQfQZzPPkVeMESHAFpJTwI62ijC7xZn1lYJY5Ia9D0 //B6JPGgKkjB9Ri1BK2xwq/s5n2f67Gg/Kj5TxaGwnTCpFJYT3Pioj+ewmd29eyVq5Lk Cj/e67GTt3HR5u2qWpOhVqM0XDuSWm8qBBs9fp+yT6GNM4NLmSn73lBYIbyYS8kO2ADK 6gKrdjDUeJUNiXjUnq68cIWv6cK/ot35m4kHOQ8bd2vMuXQd1GRcu53+xHKCvDQy0qE4 Pv9Wt+pRTMYZHdTfRzHlb/xW5njdpaVkELG2e2B8HwjZLPfqmgH+eiQxVhTdc5V6FKAx 6Ubg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TLtjDxEJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y123-20020a636481000000b003a292c2149asi14656734pgb.164.2022.05.02.18.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 18:16:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TLtjDxEJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 642A6517F1; Mon, 2 May 2022 17:55:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387164AbiEBTrs (ORCPT + 99 others); Mon, 2 May 2022 15:47:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387162AbiEBTrn (ORCPT ); Mon, 2 May 2022 15:47:43 -0400 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 DA8659FF6 for ; Mon, 2 May 2022 12:44:12 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id p18so17740476edr.7 for ; Mon, 02 May 2022 12:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KDKVWt6i2JVgFk5hQ0cN9rigyvuCgGuIi+Y1yp/hEyU=; b=TLtjDxEJVxuw3SDFmLZl8TjFa8ejjCV3hSGdqXW2sRhBwizgDwOo86ygS46gw7eTvm PBhdDyHf67jHns5ihyVOs1EfqxVt7ghQtbNRbE/sVB6sTp68ZpTvEkvn3tJjmmNJvSRw RDQaqk4afuv9yqUsvbQy0Go1AgpdtuumIJ1g92KJ3ZiNk0T9CXWokaS+GAGSn0I0TjTh Wv5u0d1BjKgGgVdwosc4UX/r5t9UGsx8DdITX0PmNMYzh34kmaq6gakslFC0c6AfQkmZ 7Dd+xJKBepC2+GMa3teQ1Z8xFFTEe31e1TKdpiAWN0Ic48syWs7ikQFT09Hing9UxufT +e2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KDKVWt6i2JVgFk5hQ0cN9rigyvuCgGuIi+Y1yp/hEyU=; b=KsyYDPyYJMhWAtdGycooBMAALHLNLHskhjErh5NTCuBxn5WolPZ3uziGuOHO8PEVZ0 xXb9ZlSyxI6qph/d9f6rdGPZUwLFnvBwzJsCPjfYjXrcHki1d0WAhpP+xeEzTqhHA3O8 AjC7LXn5UhivdY9aSfijJiDT9gYcoRcgJ2jUNJDi5QwQBBKc7E5XtOvhEn6npTfgcM83 O0w/afMRkYCsemDT8UmZrUBuMse3u8gG9TVFlHe/rZRyicdoSsjyXEpZT0ye438N0UX3 O315QZ0j3xbvWLNyjco2nQq6hg2Ow4cQNfq0RtKIkMJ1zpGQHjubXKqtSGgZWCeixQhK 9hLA== X-Gm-Message-State: AOAM5331w+1W6u00xAcGtuZsY91O0RkSBJzsj3Zxe/jGeU0pVm44+eWM 1hjHhUpZvqlYRs03+rDaLrXBQvdnCy6I6hjmtIhsEA== X-Received: by 2002:a50:d585:0:b0:425:c9db:cf26 with SMTP id v5-20020a50d585000000b00425c9dbcf26mr14841032edi.222.1651520651119; Mon, 02 May 2022 12:44:11 -0700 (PDT) MIME-Version: 1.0 References: <20220502093625.GA23225@kernel.org> In-Reply-To: <20220502093625.GA23225@kernel.org> From: Daniel Latypov Date: Mon, 2 May 2022 14:43:59 -0500 Message-ID: Subject: Re: [PATCH] kunit: take `kunit_assert` as `const` To: Miguel Ojeda Cc: Brendan Higgins , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 On Mon, May 2, 2022 at 4:36 AM Miguel Ojeda wrote: > > 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 Reviewed-by: Daniel Latypov Thanks for this, the code definitely should have been this way from the start. I had wanted to make this change but mistakenly thought the format func took it via non-const for some reason. I must have misread it once and got it into my head that we were leaving the door open for mutable child structs (which sounds like a bad idea). > --- > 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 > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20220502093625.GA23225%40kernel.org.