From patchwork Mon Mar 21 13:26:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8633251 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 E72DE9F372 for ; Mon, 21 Mar 2016 13:32:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A2AB202E5 for ; Mon, 21 Mar 2016 13:32:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 458EB202AE for ; Mon, 21 Mar 2016 13:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755146AbcCUNce (ORCPT ); Mon, 21 Mar 2016 09:32:34 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33398 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755454AbcCUN0h (ORCPT ); Mon, 21 Mar 2016 09:26:37 -0400 Received: by mail-wm0-f65.google.com with SMTP id x188so21824481wmg.0; Mon, 21 Mar 2016 06:26:37 -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=pJJqtxNKUpn7iyT9FbgZ+Vd2isRpDh4fhfRv/aLNOD4=; b=YJoFrRTBqXlNV1TDsx8gGiSPkiMiajOQ5dqwurtSFT520U4rjWJU0PE9vlbKIVhPmx hAPOF/XrDI4Iw/3iVB902sWLzjgDFOxXGP4M7/8jB20Acrv+AHaRX604kMOfR4vqaB4U 5klbWzrHpbsE72i5xuWL/wgOpto6CSl86UYLRxie6jH2nrp/vj7Dsx1J2zhhulH5PqPn ReJPwW7UAasvd1gkmLZUxMh/vdLcGTEh/zJmB1MrEtm2Xkba2VqNF6NFj0XdFBfDZOwa 90HNDYoIpWcbYRaKy7mKfCWl2vepDM4h1w0E6bp2+/imET8OLybBgrzXxX4+coXdvL14 172w== 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=pJJqtxNKUpn7iyT9FbgZ+Vd2isRpDh4fhfRv/aLNOD4=; b=XGYIZ+qNcRqdGo2nUEeee++LQ3J9r57u7+flx52W0fCKyLFLvu5XAMKONAj5WE/+KV OwYHaKAFpFJ/OTgbu9WZ/bJWEcaXrlHQmkXzSsO0RO5TnJE/1tb32lecegjzfFqSvbIx Qq5l5sJ3peHiQi3PntI5CuZYNqIctIPods+3Re87Cfi0m63h6UbToNOXPViPrYy/VJD1 zE6+uF0eAgRwoO9OVFlqUKV5RQxWnzckwO/oP5muA0tnGlKQ3igrU4nVOZl3Xv+GTCcA WvUFCFX+leMdzTVvMkJ9eLJvUPBJ28gNbFgbZBAS9rFwMLCJcQkihG0ycuzDmaWrIH0v VKOw== X-Gm-Message-State: AD7BkJLY9nfe/X4mh6e3O72S4aRmEq8PPtw84yvRb85T/Th44j35JVL3yODzjTKq3JED+w== X-Received: by 10.28.137.139 with SMTP id l133mr14785837wmd.1.1458566796395; Mon, 21 Mar 2016 06:26:36 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id u202sm12488964wmd.24.2016.03.21.06.26.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 06:26:35 -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 02/14] lib/mpi: mpi_write_sgl(): fix style issue with lzero decrement Date: Mon, 21 Mar 2016 14:26:03 +0100 Message-Id: <1458566775-5239-3-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 > 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);