From patchwork Tue Mar 22 12:12:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8641741 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1486C0553 for ; Tue, 22 Mar 2016 12:14:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBF322039D for ; Tue, 22 Mar 2016 12:14:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 931CE2038A for ; Tue, 22 Mar 2016 12:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758487AbcCVMOP (ORCPT ); Tue, 22 Mar 2016 08:14:15 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36812 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756580AbcCVMN7 (ORCPT ); Tue, 22 Mar 2016 08:13:59 -0400 Received: by mail-wm0-f66.google.com with SMTP id l68so29152551wml.3; Tue, 22 Mar 2016 05:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wRTQLfMV9mP+1ZQnvH6cpAk+P89QpPdZj2q4fjsUqGg=; b=iNk4kQBQi3R/6e4Y10nPGLgcCpppawkqrFnKmdAxIuhgR/rVJAL3dWlydOW/XZ6/mi IxhThef49Tt596kr671N7BB3cuquLUnvQhht60f6osy1NEN1dqh13EDxqCfULO11Q4Xv zABSIjozdELiJPZ7gwraifB8RHQFlemBEIG0V86wtbxWPBxJbXQ3J4IjtDGWDiljRs5l f+/qJBrESSvXaYFdk5aCBxZ24rwYwNzcYsbyFQJ3t24pCoVaX0h79LhtomGX1pltXdZB vph2WxCScjOhNgZAPMonVdvNSpJ6reWH7XqpETtc3hSACZSvxvd+WSzJjz6CrLxfzCJS nQ/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wRTQLfMV9mP+1ZQnvH6cpAk+P89QpPdZj2q4fjsUqGg=; b=Y4DXGuHuK+o+icy8Nf7TKFsJqUd2tDdMIpnvR/VZBT/xA+0KcXdB1hCnKwG0wG631+ q7zBUYNnv8Y4/lAwD+2nsgFwNMurlJm5IWQbf9Q2MZ3OVahiEYTzEhDEi4VDLnkg0ehR +Znw0f5KqsnwkS7t/3WPSFeTn+tqTnyaD4M4UGXj1ZUZvy6+5HnR8YdugTTvTaH0KzxM jNf7iyp7smYeoZVE7KfCZB4iAiLaISrQc92+/CyH4fE6uS7X/7AqpxW7ONzXYX/Purw+ Cw5IT8n/lp9tpTJPYGKlVblMlviaznmWp3iLCD9lots+/j7XyUmV2UkmHzPXMIknJJDK queg== X-Gm-Message-State: AD7BkJKN6OVTJ0BxYP3iMf8gQ13XOhegB8eCktWQU9msanDSqbViaAXFyYOmY0Vq3PZd5w== X-Received: by 10.28.9.71 with SMTP id 68mr19597675wmj.33.1458648838227; Tue, 22 Mar 2016 05:13:58 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id l135sm17149274wmb.13.2016.03.22.05.13.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Mar 2016 05:13:57 -0700 (PDT) From: Nicolai Stange To: Herbert Xu , "David S. Miller" Cc: Tadeusz Struk , Michal Marek , Andrzej Zaborowski , Stephan Mueller , Arnd Bergmann , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolai Stange Subject: [PATCH v3 03/14] lib/mpi: mpi_write_sgl(): purge redundant pointer arithmetic Date: Tue, 22 Mar 2016 13:12:37 +0100 Message-Id: <1458648768-1469-4-git-send-email-nicstange@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1458648768-1469-1-git-send-email-nicstange@gmail.com> References: <1458648768-1469-1-git-send-email-nicstange@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Within the copying loop in mpi_write_sgl(), we have if (lzeros) { ... p -= lzeros; y = lzeros; } p = p - (sizeof(alimb) - y); If lzeros == 0, then y == 0, too. Thus, lzeros gets subtracted and added back again to p. Purge this redundancy. Signed-off-by: Nicolai Stange --- lib/mpi/mpicoder.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c index d8b372b..78ec4e1 100644 --- a/lib/mpi/mpicoder.c +++ b/lib/mpi/mpicoder.c @@ -407,12 +407,11 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes, mpi_limb_t *limb2 = (void *)p - sizeof(alimb) + lzeros; *limb1 = *limb2; - p -= lzeros; y = lzeros; lzeros = 0; } - p = p - (sizeof(alimb) - y); + p = p - sizeof(alimb); for (x = 0; x < sizeof(alimb) - y; x++) { if (!buf_len) {