From patchwork Tue Oct 19 14:26:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12570071 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76DBDC433F5 for ; Tue, 19 Oct 2021 14:29:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0C28A610C7 for ; Tue, 19 Oct 2021 14:29:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0C28A610C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9F4916B0071; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97D566B0072; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 845466B0073; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 762596B0071 for ; Tue, 19 Oct 2021 10:29:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2D736181AEF1E for ; Tue, 19 Oct 2021 14:29:37 +0000 (UTC) X-FDA: 78713420394.15.793B668 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP id 5D705F000098 for ; Tue, 19 Oct 2021 14:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=XflQmu+9ZIgNRCNVo0+euXYeEM3C2NpD324hdp3HDoU=; b=LJEiAVPoKjddTWg/MKRWDmdSc9 hNDHk3rS+vSo/074CCyzzU/3BN1YUlEStwlkWgTBXb0uOnBC9GZ4DLNTcfWzjkxMSiSetwUeAnGMg wWb8jfUVvVjdhUKwD1UmOpZsj2ngp3RDwSZwa5QwLJEA0V6tZM4UCs7sGKFcbYWkWBF0qpPXj2vLC oGOmlOEBCo0YTTLGRQhyKKvHzi9LEjjjOYie7M3Islz2zOD3bHKydtq7+M75RQQ+cNJJtNAbxR9uv RsFp1G3OZzSSReM9kC3p4zA746OOdWP9uqWyYe6iUPhQH/fVqrK62YyLzHmvcGK2xFrn4ia5CKP4t OycvFUIg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcq5k-00Bn4C-L8; Tue, 19 Oct 2021 14:28:04 +0000 From: "Matthew Wilcox (Oracle)" To: Yafang Shao Cc: "Matthew Wilcox (Oracle)" , Sergey Senozhatsky , Petr Mladek , linux-mm@kvack.org, Vlastimil Babka , Rasmus Villemoes , Anshuman Khandual Subject: [PATCH v2 1/5] test_printf: Make pft array const Date: Tue, 19 Oct 2021 15:26:17 +0100 Message-Id: <20211019142621.2810043-2-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211019142621.2810043-1-willy@infradead.org> References: <20211019142621.2810043-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5D705F000098 X-Stat-Signature: e9kmet77qer6iw5hmt3imf53b69u4h8h Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LJEiAVPo; dmarc=none; spf=none (imf16.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1634653774-759225 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of assigning ptf[i].value, leave the values in the on-stack array and then we can make the array const. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek Reviewed-by: Anshuman Khandual --- lib/test_printf.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 55082432f37e..a52c1c3a55ba 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -586,22 +586,21 @@ struct page_flags_test { int width; int shift; int mask; - unsigned long value; const char *fmt; const char *name; }; -static struct page_flags_test pft[] = { +static const struct page_flags_test pft[] = { {SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK, - 0, "%d", "section"}, + "%d", "section"}, {NODES_WIDTH, NODES_PGSHIFT, NODES_MASK, - 0, "%d", "node"}, + "%d", "node"}, {ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK, - 0, "%d", "zone"}, + "%d", "zone"}, {LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK, - 0, "%#x", "lastcpupid"}, + "%#x", "lastcpupid"}, {KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK, - 0, "%#x", "kasantag"}, + "%#x", "kasantag"}, }; static void __init @@ -627,10 +626,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid, #endif } - /* Set the test value */ - for (i = 0; i < ARRAY_SIZE(pft); i++) - pft[i].value = values[i]; - for (i = 0; i < ARRAY_SIZE(pft); i++) { if (!pft[i].width) continue; @@ -640,11 +635,11 @@ page_flags_test(int section, int node, int zone, int last_cpupid, size = strlen(cmp_buf); } - page_flags |= (pft[i].value & pft[i].mask) << pft[i].shift; + page_flags |= (values[i] & pft[i].mask) << pft[i].shift; snprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name); size = strlen(cmp_buf); snprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt, - pft[i].value & pft[i].mask); + values[i] & pft[i].mask); size = strlen(cmp_buf); append = true; }