From patchwork Tue Mar 22 12:12:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8641721 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 53EF6C0553 for ; Tue, 22 Mar 2016 12:14:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 76CB92038A for ; Tue, 22 Mar 2016 12:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 994B52035B for ; Tue, 22 Mar 2016 12:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758450AbcCVMOM (ORCPT ); Tue, 22 Mar 2016 08:14:12 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36780 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756204AbcCVMN6 (ORCPT ); Tue, 22 Mar 2016 08:13:58 -0400 Received: by mail-wm0-f68.google.com with SMTP id l68so29152301wml.3; Tue, 22 Mar 2016 05:13:57 -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=PVqX5woP852Q25DL8h+JttUvBULNKTLAlB6ihReQkv0=; b=ARHp1HXhsXSzoT15lHybL9sixKTJlsx+COkQuiv05jO4hUd+1hKjZeJ5c64aJ2BIv1 jlgi2foVBUjGVFunbIuJSrE5VQmkl65/JmcHumWtsAKRtq8y+6CZvyyh+B3cLinTofu0 PepYs44YBM+MJIoSDcGMvT9UL2BujK6LSBbIZOKePou1G2dnBWLM55BOaAFJbgm0QVGk s0dCEOKPmBQkw6asYPDTpeONuL0acw3N3TlEI5O5XUsoGUO6WMwW1TuSDKKiDdejwJ6Y 1mIGBV2zSV9yvyph3CBdz6FoJdL9Ms0oXvmHJUgQzguLtSQO2BevmtDKO74Kmstljssa W6mg== 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=PVqX5woP852Q25DL8h+JttUvBULNKTLAlB6ihReQkv0=; b=MGJVlKTFVzcjyrPzKRgBW+j/AsSxXpm2dLd1YrdvtDFBhyL0TQW1m+nj9z8gvbHBvr iEdeJlU9by3oHH0oLeP/60Viws4TmG38wCsNV+M/erDnPa8Bwa0vkiZ0CyvSQwgcxfx/ LVEvlAQdIuC0EtoyaWkcNW2FsLrzLkVojGamL+VyEzS4o5SpUo/U6VpGzya/Kr5yTjXS fXI74y7qE70eV+cmkDjZ3ZrC/yoJnMMWATMJTLSutC7onpa79SAM91n4dJqYyfd4QQu9 +OxvHuk4MAQRN/H9SrUH8D5eGTkTco/NvE+vUOjpnz9w7kzq0nGWjpgBMldXi7mLbwZf TVqw== X-Gm-Message-State: AD7BkJL7Aq97S2oI0nJnTOjTqwb0zWu5k4FGGqego0OS6zH7UpuxbrTq8akHSkvZDqbQZw== X-Received: by 10.194.78.129 with SMTP id b1mr35341250wjx.60.1458648836726; Tue, 22 Mar 2016 05:13:56 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id h7sm17059996wmf.9.2016.03.22.05.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Mar 2016 05:13:56 -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 02/14] lib/mpi: mpi_write_sgl(): fix style issue with lzero decrement Date: Tue, 22 Mar 2016 13:12:36 +0100 Message-Id: <1458648768-1469-3-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 > 0) { ... lzeros -= sizeof(alimb); } However, at this point, lzeros < sizeof(alimb) holds. Make this fact explicit by rewriting the above to if (lzeros) { ... lzeros = 0; } Signed-off-by: Nicolai Stange --- lib/mpi/mpicoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c index 6bb52be..d8b372b 100644 --- a/lib/mpi/mpicoder.c +++ b/lib/mpi/mpicoder.c @@ -402,14 +402,14 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes, #else #error please implement for this limb size. #endif - if (lzeros > 0) { + if (lzeros) { mpi_limb_t *limb1 = (void *)p - sizeof(alimb); mpi_limb_t *limb2 = (void *)p - sizeof(alimb) + lzeros; *limb1 = *limb2; p -= lzeros; y = lzeros; - lzeros -= sizeof(alimb); + lzeros = 0; } p = p - (sizeof(alimb) - y);