From patchwork Mon Mar 21 13:26:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8633091 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7706C9F372 for ; Mon, 21 Mar 2016 13:30:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8013B202E5 for ; Mon, 21 Mar 2016 13:30:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F6EB2026F for ; Mon, 21 Mar 2016 13:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754583AbcCUNaI (ORCPT ); Mon, 21 Mar 2016 09:30:08 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33412 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755652AbcCUN0j (ORCPT ); Mon, 21 Mar 2016 09:26:39 -0400 Received: by mail-wm0-f67.google.com with SMTP id x188so21824669wmg.0; Mon, 21 Mar 2016 06:26:38 -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=7p/yyiDi/HNXiGz/uzuV/auG0+nNIeaAYJsFMP8iQrI=; b=Ggah3aX0eujKuQ0vskGg7R34zz+becWQA8Lg0jWYn5/T1o0EQvkED+VWsUAA3rkS3V 9ktU8cLDUJLrJd7GFjmzvXN4wCUtERxY4Obl0KeUWc4RL8D5qTxrrLZZy0vdPypTgREV 6bZKxk7/UwWB1+s5QCiJX1b8ILa3DRtZ5fy1964fmVy2Rnu+907YDkxl6ukOO55OovO4 WTjyIDAdLVsEZUnwpQqQn9wuSLBGmXTbVLwJOtzTnLB3lGUj71mKRBft8Lwl3hA5PXrr UWlV+jVGukVH2EEPtAd/9f7k7XepxU65Ynr7y2Wb8cCMq0G69HR2iJltqaFFw1aaa4Za TNSQ== 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=7p/yyiDi/HNXiGz/uzuV/auG0+nNIeaAYJsFMP8iQrI=; b=MtGYF+7AYtoaTV96Ex/Bk4+fXqZGQnI6MKwLGfTvojx1npH2+cVQl2morywQFE27cy 0XqV5/fpbjg8iug8fPtNHieB7hTqIyzQj8tp8RnM9CWXJOKrs6S42jcd3F9Lf4jqwOcJ iUxtEalG5V17cw8XAPoEDgOZH22Pu/M1CZv+IxV3LCsmWkPjsy1tT8I4NxPuu2YdLqzs PXKTKlLeBXlUfOVhBg6Sb1OCE5vPLnOYOevxXIVxvgPVmj4rrlseZoYkeM5kx3oNeC5E +M0En8qlpXDPmrrlWFXp+D1TCn7NaIkURMht6clZNN7m9uD3iLMhn1lGlskkyZgBmPkU IjBg== X-Gm-Message-State: AD7BkJL36YL7fFKbj2AddJh4tsQsHLPCft9NLOc/OS3eVIcbx6SnH+4qzGhlDywCqkS7aQ== X-Received: by 10.194.184.139 with SMTP id eu11mr34535737wjc.169.1458566797959; Mon, 21 Mar 2016 06:26:37 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id t3sm25378880wjz.11.2016.03.21.06.26.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 06:26:37 -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 RESEND v2 03/14] lib/mpi: mpi_write_sgl(): purge redundant pointer arithmetic Date: Mon, 21 Mar 2016 14:26:04 +0100 Message-Id: <1458566775-5239-4-git-send-email-nicstange@gmail.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458566775-5239-1-git-send-email-nicstange@gmail.com> References: <1458566775-5239-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, RP_MATCHES_RCVD, T_DKIM_INVALID, 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) {