Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1523717pxb; Sat, 29 Jan 2022 08:25:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjFsiRWk89HzJb8U6p7M+/t43GiemgE238Q4h2jqVi99x+cx5P6jF3d0yFSDrhob/OCQYv X-Received: by 2002:a17:907:7286:: with SMTP id dt6mr11250462ejc.503.1643473536679; Sat, 29 Jan 2022 08:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643473536; cv=none; d=google.com; s=arc-20160816; b=FVlGR0IuHLDqjzY0ewYDjqk/fi/yw+Xf4CCqttN7CJJzIU3vuDmzrBWT0cxc1x/i4X aIxpO/nm/TI7ObGF3u6InDU6YQZM30ioSAlAJX7aYIw/rXM97hLlb3D8G1U5KOBdWt55 IDXEVPLm5KQjKQJAAXdYLXDLi+tfxsdqn6O1SGh6Y3vktzKNNlAQu8NvoaPx/cCpbgmq HLvAE+jqcY+B6w2ONmCzX8D5QVktaF0Ua33b09FaraSIEYAyboKCSWxiqpaLWaDQr3Au uAcPsIHwkiFIkMIXTB52lJpmhMU7wJ/ZB8nZUgg6p7N5hA2ksp1w3IQltvlqPms3tkIa p6Fg== 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=NjMVNnFHw5l0SfQ5jsSi4cfE7ZyRsd0RS1s9FDyEMkM=; b=dy9stjgelRguUY/2Qut3qIe5B10hv+3p7BS88U+IBCHV94kW87xaHlWH39p/azKcb8 WtZD45oBdFDoVljNWZpEpqVsEZa/Zp6dbQvxojevxmXLfc+0UHJ/8z6AvyZE4iSs8qWj /YMbqGd5VvLfzMfxt0883EhpA4Ni0yvhsLnZ1KmTRBdwrBJZqMHWcBKhb7s+v3gj8miF L3jYCIgTVmP4UIW33Omzgb5sa8caAN6+Q+GNVkd1fNaURzDcHEcudWjmuPnbFNrQoiHJ P+X767Uh7yQ4eR5iGyikGImF1iiJyW1gtC350CRuZeJAMXr99Z5+GL8hpIv92DAzLNhy /IgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YuTuDc9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si1204320edq.358.2022.01.29.08.25.10; Sat, 29 Jan 2022 08:25:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YuTuDc9D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346067AbiA1EgC (ORCPT + 99 others); Thu, 27 Jan 2022 23:36:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237463AbiA1EgA (ORCPT ); Thu, 27 Jan 2022 23:36:00 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16342C061714 for ; Thu, 27 Jan 2022 20:35:59 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id u15so8546708wrt.3 for ; Thu, 27 Jan 2022 20:35:59 -0800 (PST) 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=NjMVNnFHw5l0SfQ5jsSi4cfE7ZyRsd0RS1s9FDyEMkM=; b=YuTuDc9DAfgYJkx9ivUhquM9vU+HCogTo5W5T9biL0smE3wnwMLh2lIc9HPVJcFQvw qkW+EhLNxQRxNVtYj16ro3C+N7J3oPFuFBvTAapIa3I5AxmSwbTONuln75vn+NqFx+zT U6voGOy8puLmzyQWf03ecJkq3hbxvO4NT57FAUyaNf4CYo0v5qDo44U7N2u7wfCUSOcp mnDM0tyHAt23lBGdUorDIratSEDq075JZTqd5rvOIW9uWV9XTon3KK/vJWMkrzFV/2jq hGGrK5wE9OelYNj2odHo6kcTXXBaHkgh5JW+asknpBRkmQrBeK8S3AUlgA7rKAK0oBpt c5YA== 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=NjMVNnFHw5l0SfQ5jsSi4cfE7ZyRsd0RS1s9FDyEMkM=; b=2fkyw7D7rIAZCrfvS4k1lUggOxKKrXM97Tht27JJplQTmXc0CD8dSJF1ThkuMS9qDO GCIG7KrFMwTnhel3EvEq6WT2fBJLNL17+iOCtDETJYv+PfbysXJ69MTWYTPLU/GaxCWG auz4PklxqWwfYgFhCWpztfKMek3xZF3s8PbnTMzgIcYMWIcadcrhcLfo1VOnsZemv7DW kNzHF2Wbn0hKyn0cX7hzGwRsmTjkmXKTf6HWzCP5s2lG4iT6HkV27Wzgy3PKzcMt5ttJ GUqVcxR2ZbC1HYvrYzi4CefbnL05qcXG5JQnb6OrN34uRwRka3TNFvwQwveemViJKVtq Q+2A== X-Gm-Message-State: AOAM5313RW6TbzhGfbv8E0ozJxXeKng94qfy8o5G9a+RQVcxDEeEVjuP rY03FB3DsXqnUCfbCf8sgRflz+xNH06JHaBH81xO7ZoUIGU= X-Received: by 2002:adf:fb05:: with SMTP id c5mr5627495wrr.220.1643344557501; Thu, 27 Jan 2022 20:35:57 -0800 (PST) MIME-Version: 1.0 References: <20220127215222.159049-1-dlatypov@google.com> In-Reply-To: <20220127215222.159049-1-dlatypov@google.com> From: David Gow Date: Fri, 28 Jan 2022 12:35:45 +0800 Message-ID: Subject: Re: [PATCH] kunit: cleanup assertion macro internal variables To: Daniel Latypov Cc: brendanhiggins@google.com, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 5:52 AM Daniel Latypov wrote: > > All the operands should be tagged `const`. > We're only assigning them to variables so that we can compare them (e.g. > check if left == right, etc.) and avoid evaluating expressions multiple > times. > > There's no need for them to be mutable. > > Also rename the helper variable `loc` to `__loc` like we do with > `__assertion` and `__strs` to avoid potential name collisions with user > code. > > Signed-off-by: Daniel Latypov > --- > Note: this patch is based on top of > https://lore.kernel.org/all/20220125210011.3817742-4-dlatypov@google.com/ > There is no semantic dependency between the patches, but they touch > adjacent lines. > --- Looks good. Reviewed-by: David Gow Cheers, -- David > include/kunit/test.h | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/kunit/test.h b/include/kunit/test.h > index 088ff394ae94..00b9ff7783ab 100644 > --- a/include/kunit/test.h > +++ b/include/kunit/test.h > @@ -779,10 +779,10 @@ void kunit_do_failed_assertion(struct kunit *test, > > #define KUNIT_ASSERTION(test, assert_type, pass, assert_class, INITIALIZER, fmt, ...) do { \ > if (unlikely(!(pass))) { \ > - static const struct kunit_loc loc = KUNIT_CURRENT_LOC; \ > + static const struct kunit_loc __loc = KUNIT_CURRENT_LOC; \ > struct assert_class __assertion = INITIALIZER; \ > kunit_do_failed_assertion(test, \ > - &loc, \ > + &__loc, \ > assert_type, \ > &__assertion.assert, \ > fmt, \ > @@ -872,8 +872,8 @@ void kunit_do_failed_assertion(struct kunit *test, > fmt, \ > ...) \ > do { \ > - typeof(left) __left = (left); \ > - typeof(right) __right = (right); \ > + const typeof(left) __left = (left); \ > + const typeof(right) __right = (right); \ > static const struct kunit_binary_assert_text __text = { \ > .operation = #op, \ > .left_text = #left, \ > @@ -956,7 +956,7 @@ do { \ > fmt, \ > ...) \ > do { \ > - typeof(ptr) __ptr = (ptr); \ > + const typeof(ptr) __ptr = (ptr); \ > \ > KUNIT_ASSERTION(test, \ > assert_type, \ > -- > 2.35.0.rc2.247.g8bbb082509-goog >