Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp551187lqs; Thu, 13 Jun 2024 20:09:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbhwyp4Kd1BUyjPABjNDVElWrM0AZTh8YdKG2X2WNqmV9JnDGCw7TW24F6mpRSv0QGRo0y0il3f73wcwTbLEJkKxVYO0gZTnD5jShqYg== X-Google-Smtp-Source: AGHT+IGuHGKZOA3UdU3oK+AVDR6YZ4/xid8OPsgVLQ/q59IeCeL6YWe0vTIVo1eQyPII0WAee41S X-Received: by 2002:a17:902:a3c5:b0:1f6:78d5:f40b with SMTP id d9443c01a7336-1f8629f9b67mr12697195ad.51.1718334597449; Thu, 13 Jun 2024 20:09:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718334597; cv=pass; d=google.com; s=arc-20160816; b=j4cwHE7wV4CqezT7Ia5tkyGkSYGpdVZMetkgb1WqCCViVQfMRqRuBsfUMJ15DrNWfI h8i5KSMvIJAyZt/YYN05/7CSJzae5RdeczKJM7wH1tGIBBs/cLFrmgCUMemp17rzhQa+ F7tBIX4luA7rcxGYAOrcyLKUzTOIuXHf25tfr7ahqrreGx/qcAMGYLqZeFFLuGSSrowE 6fO4NRGfvyOW+bjCc3y/MT0kqsVlQfP+PcGbHMoqiVzm5Yli54V4DMJPjwA9fyj4oD0y eUKLxNuNSw6cBvTZLNqFscvtbpM59+mwJ8017JQDHAhFO0Pj8HoRh+Icri0vBGuQTXRK O5Dw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=oW51X77H6y2z8dhDzEhe+nNMSEceLAr8XPtl4dHoY8Y=; fh=oSYnFTjqnBbOn4+yb9ccg8OVfyjHUlawIVEMFbCDy4Q=; b=dwcDttBPdCzB+XRNQSFIT68JWLlzIjzVDy7PCv7rMeY8h3tr+FRYzsKx5CK06GHzA5 gN0pNsHZqubiwDk2IjSPhyN086DMNb4lURDa5TE4bJJeI6n0rx5XX6wE0hiKEFDcu2bk W0PXWYE/IMiyReCovejE5TSfpMi5EJdt9vvOr88Lp3xXZl7nUZ62n4Qfq4kC6pM+J16r Gr8rCdENC0WLPQAk0h5aBiTBhaX+7JcXBDlxS7wqQso0PBgELkk05OXPikXyK07RLXm9 i06PTASjE29lDGVLqfn5Wr3+Hvco6iOiulII3KhemALvPNu7Bj79NhUGdQ/1QApktrUN LpgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=yfuElC3U; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-crypto+bounces-4930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855ee192esi25599265ad.365.2024.06.13.20.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 20:09:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=yfuElC3U; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-crypto+bounces-4930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 148332844FC for ; Fri, 14 Jun 2024 03:09:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 940F9184108; Fri, 14 Jun 2024 03:09:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="yfuElC3U" X-Original-To: linux-crypto@vger.kernel.org Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4F201836E5; Fri, 14 Jun 2024 03:09:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718334578; cv=none; b=hPprhsO62TiipWNHeLGZxFu3oq6eS6PLIlOvweNm5js3RSVYcTE8LetSjAn4s0mkDC4jP1AsUY6tuUnLwt1z8hWMPz0tOsz/V3rZpHS4ZqOTKVMR/LEB5+33e1LNyXt6DaKvlnMG/oOzXp/xfTz+LNNxAxVDBIDp+tlYdBO8H9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718334578; c=relaxed/simple; bh=079fmPcNrElpCqv3Y6BnAIOUYP4AOMMQoKL0HG/iaIo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pZ/SwOlfMCR+Df1xSl5LW96y0iLEB3UpszpNUHJj040NfG+63llYHy36BlpJw+pb8jfX27yl760OresdXErtsXHigCyE5trqSQOBJEn4tVtXp+Cgw61wmWYX/JQOPv0D0Vy9cdy4sXA2/lpcvaM/e0Wf94uDS0Mafv0SfXFxXoY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=yfuElC3U; arc=none smtp.client-ip=115.124.30.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718334572; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=oW51X77H6y2z8dhDzEhe+nNMSEceLAr8XPtl4dHoY8Y=; b=yfuElC3UkSEJOT8Ba4NJ3GDA/MAxVmv9/y9EER6MEf3u4+xIvT9tzx2UUP/T3h2TWa4jaATMivMSQenwj0ZnZYjGqlZtp03vtPN26RR95M4vMLWl6c5ccNl0DjZfeCVzgXJqY6+IjFku000ItOfh52sOYpOJ3/vpMfg3OEX9wzI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033068173054;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0W8PpsGW_1718334568; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0W8PpsGW_1718334568) by smtp.aliyun-inc.com; Fri, 14 Jun 2024 11:09:32 +0800 From: Jiapeng Chong To: herbert@gondor.apana.org.au Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] crypto: lib - Use swap() in mpi_powm() Date: Fri, 14 Jun 2024 11:09:12 +0800 Message-Id: <20240614030912.10736-2-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c In-Reply-To: <20240614030912.10736-1-jiapeng.chong@linux.alibaba.com> References: <20240614030912.10736-1-jiapeng.chong@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use existing swap() function rather than duplicating its implementation. ./lib/crypto/mpi/mpi-pow.c:211:11-12: WARNING opportunity for swap(). ./lib/crypto/mpi/mpi-pow.c:239:12-13: WARNING opportunity for swap(). Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9327 Signed-off-by: Jiapeng Chong --- lib/crypto/mpi/mpi-pow.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/crypto/mpi/mpi-pow.c b/lib/crypto/mpi/mpi-pow.c index 2fd7a46d55ec..67fbd4c2503d 100644 --- a/lib/crypto/mpi/mpi-pow.c +++ b/lib/crypto/mpi/mpi-pow.c @@ -176,7 +176,6 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) for (;;) { while (c) { - mpi_ptr_t tp; mpi_size_t xsize; /*if (mpihelp_mul_n(xp, rp, rp, rsize) < 0) goto enomem */ @@ -207,9 +206,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) xsize = msize; } - tp = rp; - rp = xp; - xp = tp; + swap(rp, xp); rsize = xsize; if ((mpi_limb_signed_t) e < 0) { @@ -235,9 +232,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) xsize = msize; } - tp = rp; - rp = xp; - xp = tp; + swap(rp, xp); rsize = xsize; } e <<= 1; -- 2.20.1.7.g153144c