Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp318702lqb; Tue, 4 Jun 2024 12:17:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgtR/DZoJoXzQrZGHW3C+f+OHR2CMs7h2ZE3gHm6iaokefxLmCLc++9vfM82oZQcb7tToUiF34ySYvHzCP/EUjesv1qR1H0tN54uOSgQ== X-Google-Smtp-Source: AGHT+IHY3HAi1ilxWQnD099hOnYmNudHhUbN1kbeQYJdTUY29h+S7AToJdQylIWWD0eOz2LtQ5G/ X-Received: by 2002:a17:90a:b005:b0:2c1:99a7:3cb with SMTP id 98e67ed59e1d1-2c27db5a1aamr381430a91.38.1717528628282; Tue, 04 Jun 2024 12:17:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717528628; cv=pass; d=google.com; s=arc-20160816; b=aNbux9MU1lHsz9FVqTwfR++xtxDZadNXEIKad+uh8gZRhr+ar2UjWOATrwSmzOYJei cZfeZcgD4o0Mz77Mtf2QU4z4GNti0Qu8wUmlWnAOaTNcwePueR58/wrl07D+T91oOWbg CdBHar/rkmlepuXF4Wu+Nv+WeVLT7jPBIc0xzTYPDbvGsmdPtjg0l/ZBbtd9yAGhIw74 L1De83CfngTyZb4T9eh41sZlKPPHR69pq5/OCQwkw2DT71GexuxF55U9XB0gfgSRSNmU wSKaEOSgP+JoDLdhOAC+fgMHRgNWHJlADL9n+PY6wja1G5lh46mzppIJLVNR/SA2bWlg GoTw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=3BF8/GItxoat+r6e4T4fHLj85BE2y/O2eJbYc1bfqVo=; fh=Fdh1YyjLL9j8nosdwR1I7EQY8YOXnRGI8iflmDnBFKw=; b=pCp34TdF1ahsOZo8P/2fXaEbGb24AEH6pnpHdD20SRMe28dDmv9mqbX9/uqE8MyeQz t0Zy95/MOi5s+PQ6f7xuxDMorrhHCF7LRm5qTzZAotJN7hELo0OHuDWOwEJ0vIY+ji/l wRJIYR+ExilHBUtyoO+v0PtZvVhrB2BECZQoE3UvzisX3Q1v5RE7tjJ1eIBQZa2I+r9n 24WyNgJZoxf66F1GP9gNiR7/0zOYeHNk3aYmX+KOwsHLSeuolhGdzKUN7KCwpTb52W6N qWOE+gVom1mqKkr7A6NEYxlYeepZLJfhOBwIjCMRV9j0UXXBSdZZTN+N6rqcGvLjEZ34 vb3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@toblux-com.20230601.gappssmtp.com header.s=20230601 header.b=icO6sQ9n; arc=pass (i=1 dkim=pass dkdomain=toblux-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-201230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201230-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a7764ddesi2621826a91.16.2024.06.04.12.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@toblux-com.20230601.gappssmtp.com header.s=20230601 header.b=icO6sQ9n; arc=pass (i=1 dkim=pass dkdomain=toblux-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-201230-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201230-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5427FB22CE3 for ; Tue, 4 Jun 2024 18:09:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A29DD14A0B8; Tue, 4 Jun 2024 18:09:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=toblux-com.20230601.gappssmtp.com header.i=@toblux-com.20230601.gappssmtp.com header.b="icO6sQ9n" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECE6B149006 for ; Tue, 4 Jun 2024 18:09:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717524581; cv=none; b=Zqv9m93nbK5ceZhtTtv3h3FWbbQrBE88HKt0CNILfhO7GJ7t1ANva1ikOZdBHOLXbJ13OQWHAciNeejplDE0XGFsNoxuy/A+0j0DUi8GBX/OEeXRCUiE1mrJl27CmwR6HIwNHHxFE0TwrLM2ezN7tOlUF5eLki/B8TpnkOqVEm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717524581; c=relaxed/simple; bh=zlFWfsNQMx3Sd1wcaWh6ZJ1CoD/mFgMKL5nAugZkz7c=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=r/836DSsw+egA4Gxjkm18EWuNcn06XKL5L4YN/EyYR35D1pXyH5d+VZsXUWy3RsGezyv864Dolu930wzA4XQ2gsHjvHRHvOXSGoRvOWhx8MPhB2MZB4VaKvKtMCysh91ww/cl20MTEss9Bd3HDXEaRQ1N+tjwMcvGHZkPBib6/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toblux.com; spf=none smtp.mailfrom=toblux.com; dkim=pass (2048-bit key) header.d=toblux-com.20230601.gappssmtp.com header.i=@toblux-com.20230601.gappssmtp.com header.b=icO6sQ9n; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=toblux.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=toblux.com Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e73359b900so14832421fa.2 for ; Tue, 04 Jun 2024 11:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toblux-com.20230601.gappssmtp.com; s=20230601; t=1717524578; x=1718129378; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3BF8/GItxoat+r6e4T4fHLj85BE2y/O2eJbYc1bfqVo=; b=icO6sQ9nYKhBglMTDc1Q6bEW9B1kSlQ7SIoK2XI3RDoOyqMEWUaoO73UtpTFEkxI4n d016IgL0BRSGE/A4k9yQb+UCNQXepe+uey+Z6fMvQi7tbdlEChx4Mgsqs+KF+neFDDEH kBNZdfHRtykgxbiscS8XtS2ZBTUO2zZozv6Y9ONthxbGHPtZck2qXQcs5lcaPEDy9amk p7G//WxSD4sAwPr+PvpwPE/L1+E2sEAo+5hrQ/qjQpDf0xJp78eMGeoRNpAQTPLcisFk SlvGLErc+YE4o/UYmkB1txiXJWnWWShzkjmls/nPirjqJvcIlazkWPstrozI4SvrZrK1 kx6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717524578; x=1718129378; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3BF8/GItxoat+r6e4T4fHLj85BE2y/O2eJbYc1bfqVo=; b=IUzC2QtS1Wwfygo9RUOuW5+t2BRRXqL2Fx+top5d3bsZ+TjvxCPe3E5yECDaKsx+sa soJbp+QniEeyO7tI262pn6+SnekjiOne9g2LaaSmD6/8MP56UbEtzCceVH0roP4kggyV 8fQMxDWQWOYdc/6DAxCb5BBmSBKRvDJynktCJQz+NTIVFyX/RECWQI1JTdhVehxdja84 LbUWMPVU17o9Zcy0Vp03beyaf+tVoBV+TfqGa6CUU434pNH0xeVhXL87cKsgH1goZtBr gokPLTAjvc4Oss0fjPiGGjLtRYZeKox9UmayMSgHFDPLfrQ5eNfX6AgFUKSnADuYpiYo C9fQ== X-Gm-Message-State: AOJu0YxukBENUPfKBFXpDSIpLS3ZZ2JKnjYkKMllftG/ST//6uw9/y3A GSrzViY3TnygjC4R5D9esgPfTjQLoTlxRnMF91iGGomx7AwlNSmXUIofzNCGNpk= X-Received: by 2002:a2e:800e:0:b0:2ea:8291:c669 with SMTP id 38308e7fff4ca-2eac7aad160mr184191fa.44.1717524577695; Tue, 04 Jun 2024 11:09:37 -0700 (PDT) Received: from debian.fritz.box. (aftr-82-135-80-160.dynamic.mnet-online.de. [82.135.80.160]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4214fdf4953sm27451925e9.25.2024.06.04.11.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 11:09:37 -0700 (PDT) From: Thorsten Blum To: peterz@infradead.org, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com Cc: linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH] locking/ww_mutex/test: Use swap() macro Date: Tue, 4 Jun 2024 20:07:07 +0200 Message-Id: <20240604180705.257033-1-thorsten.blum@toblux.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fixes the following Coccinelle/coccicheck warning reported by swap.cocci: WARNING opportunity for swap() Signed-off-by: Thorsten Blum --- kernel/locking/test-ww_mutex.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 78719e1ef1b1..252bef786aef 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -402,7 +402,7 @@ static inline u32 prandom_u32_below(u32 ceil) static int *get_random_order(int count) { int *order; - int n, r, tmp; + int n, r; order = kmalloc_array(count, sizeof(*order), GFP_KERNEL); if (!order) @@ -413,11 +413,8 @@ static int *get_random_order(int count) for (n = count - 1; n > 1; n--) { r = prandom_u32_below(n + 1); - if (r != n) { - tmp = order[n]; - order[n] = order[r]; - order[r] = tmp; - } + if (r != n) + swap(order[n], order[r]); } return order; -- 2.39.2