From patchwork Fri Jan 14 22:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12714080 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C3A3C433EF for ; Fri, 14 Jan 2022 22:05:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8C9A6B00ED; Fri, 14 Jan 2022 17:05:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3C3B6B00EF; Fri, 14 Jan 2022 17:05:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88E9E6B00F0; Fri, 14 Jan 2022 17:05:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0239.hostedemail.com [216.40.44.239]) by kanga.kvack.org (Postfix) with ESMTP id 7493B6B00ED for ; Fri, 14 Jan 2022 17:05:51 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3AAA7181C49C0 for ; Fri, 14 Jan 2022 22:05:51 +0000 (UTC) X-FDA: 79030275702.18.213E6AA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf09.hostedemail.com (Postfix) with ESMTP id C2FE9140004 for ; Fri, 14 Jan 2022 22:05:50 +0000 (UTC) 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 CC3E961FB7; Fri, 14 Jan 2022 22:05:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 080A3C36AE9; Fri, 14 Jan 2022 22:05:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642197949; bh=nzmXekE0bXlfnawVvQP/czFiiwQFPyO2nhpHEMNdO+Q=; h=Date:From:To:Subject:In-Reply-To:From; b=oMuIx1oAYAWJvA+cjZNp7XEeemlU6Rq19G63ka4jbIcL5prBkXz+I4dJBl541j25K 27N05x7AN4TRtxCP0J0V4gSiYr98XPVS5Z16kSPkR2ozcBoPwA4ksSV9E7LtxXKRxp nh6TyGhH/tYwESNW9x9c7GWV7Ka8AnFAPxir1/uA= Date: Fri, 14 Jan 2022 14:05:48 -0800 From: Andrew Morton To: akpm@linux-foundation.org, chi.minghao@zte.com.cn, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, zealci@zte.com.cn Subject: [patch 054/146] tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner Message-ID: <20220114220548.cmlrzhxJX%akpm@linux-foundation.org> In-Reply-To: <20220114140222.6b14f0061194d3200000c52d@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: C2FE9140004 X-Stat-Signature: hfcrxoqugc5tmutn18ijt7s6pnpf97ix Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=oMuIx1oA; dmarc=none; spf=pass (imf09.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam03 X-HE-Tag: 1642197950-535998 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: From: chiminghao Subject: tools/testing/selftests/vm/userfaultfd.c: use swap() to make code cleaner Fix the following coccicheck REVIEW: ./tools/testing/selftests/vm/userfaultfd.c:1531:21-22:use swap() to make code cleaner Link: https://lkml.kernel.org/r/20211124031632.35317-1-chi.minghao@zte.com.cn Signed-off-by: chiminghao Reported-by: Zeal Robot Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/userfaultfd.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/tools/testing/selftests/vm/userfaultfd.c~selftests-vm-use-swap-to-make-code-cleaner +++ a/tools/testing/selftests/vm/userfaultfd.c @@ -1417,7 +1417,6 @@ static void userfaultfd_pagemap_test(uns static int userfaultfd_stress(void) { void *area; - char *tmp_area; unsigned long nr; struct uffdio_register uffdio_register; struct uffd_stats uffd_stats[nr_cpus]; @@ -1528,13 +1527,9 @@ static int userfaultfd_stress(void) count_verify[nr], nr); /* prepare next bounce */ - tmp_area = area_src; - area_src = area_dst; - area_dst = tmp_area; - - tmp_area = area_src_alias; - area_src_alias = area_dst_alias; - area_dst_alias = tmp_area; + swap(area_src, area_dst); + + swap(area_src_alias, area_dst_alias); uffd_stats_report(uffd_stats, nr_cpus); }