From patchwork Tue Mar 22 12:12:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8641881 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 D995A9F294 for ; Tue, 22 Mar 2016 12:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBCAE2035B for ; Tue, 22 Mar 2016 12:16:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2346C202FE for ; Tue, 22 Mar 2016 12:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756561AbcCVMPz (ORCPT ); Tue, 22 Mar 2016 08:15:55 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35924 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758356AbcCVMOJ (ORCPT ); Tue, 22 Mar 2016 08:14:09 -0400 Received: by mail-wm0-f66.google.com with SMTP id l68so29153751wml.3; Tue, 22 Mar 2016 05:14:08 -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=1xCcykE92c+BQsQcRJ483TJjD7yNxjwv9aYDamT4u7E=; b=TZLPAHfDNiq2tNk0X6331/7NjJmvbc3HZ+VOzGIdyb8+82c8z+tsCbvJj762SA1tPB cLOlbuJJVvdpAgdrb1SsLxRU633m0UwKTp2acZFrFA85n/FvOS45yNOhU5t/lfZotPyS Emb84hi1LHee5vssf8nI8nWnvOFsdtYAcB59ViXKLr8Imd3zwf05ccGKzwtNVFAzEnEW trNEhGsq2pT3tOD7GOta0MxyQ6/hiDfLeSj6r2XdNbL/BdOxETY7gS0MHJBMdmLf10Rw +m1oOB9p453IXM7Cm7zmv3OPWO0YwEJsjE6SnlNKMNqfGi3NERyfDvIkskpzh+SPAPD6 UhPA== 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=1xCcykE92c+BQsQcRJ483TJjD7yNxjwv9aYDamT4u7E=; b=HxgC1/+wWKS3Jh65/GN0mDwnTWb17tT/tcGDOgoq2QC/6Fkmvk3apSfVHbVpT7xkPt haRoLnFwuA+W4ygwAyUmEybRBd0ug2DTe+YDKTuP1AyUayIdWkUT4tvLYG4zMAjzeNbB 3quzNkWK4GqCW3opvSsHpGj0UKpuFlH4CJ17ITIO0BIT3Sd/SihK9a8cLgXpke00WE1g m95lp/mOjkapnKJqYMFi2TCjpbqWuK224EU2y5kIjLbNOHlEeZ8ysdKjQU26asLMvKLE g0NNrkTpvLy0UR7y9JK9Z8+jVJUfxeuw8/PHCzUs1IYx43EfJKYPYDria3BxgTk6+w4q FNJA== X-Gm-Message-State: AD7BkJIWKjhqvnaEntXScgXFgHpBFFSTZ8DqlnZMm7KXL1vWfo9K4cV8uDMVsFg//T/SZA== X-Received: by 10.194.120.99 with SMTP id lb3mr41566106wjb.59.1458648847385; Tue, 22 Mar 2016 05:14:07 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id n66sm17180986wmg.20.2016.03.22.05.14.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Mar 2016 05:14:07 -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 09/14] lib/mpi: mpi_read_raw_from_sgl(): replace len argument by nbytes Date: Tue, 22 Mar 2016 13:12:43 +0100 Message-Id: <1458648768-1469-10-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 Currently, the nbytes local variable is calculated from the len argument as follows: ... mpi_read_raw_from_sgl(..., unsigned int len) { unsigned nbytes; ... if (!ents) nbytes = 0; else nbytes = len - lzeros; ... } Given that nbytes is derived from len in a trivial way and that the len argument is shadowed by a local len variable in several loops, this is just confusing. Rename the len argument to nbytes and get rid of the nbytes local variable. Do the nbytes calculation in place. Signed-off-by: Nicolai Stange --- lib/mpi/mpicoder.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c index d995a4c..048f0aa 100644 --- a/lib/mpi/mpicoder.c +++ b/lib/mpi/mpicoder.c @@ -418,15 +418,15 @@ EXPORT_SYMBOL_GPL(mpi_write_to_sgl); * a new MPI and reads the content of the sgl to the MPI. * * @sgl: scatterlist to read from - * @len: number of bytes to read + * @nbytes: number of bytes to read * * Return: Pointer to a new MPI or NULL on error */ -MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len) +MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes) { struct scatterlist *sg; int x, i, j, z, lzeros, ents; - unsigned int nbits, nlimbs, nbytes; + unsigned int nbits, nlimbs; mpi_limb_t a; MPI val = NULL; @@ -455,7 +455,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len) if (!ents) nbytes = 0; else - nbytes = len - lzeros; + nbytes -= lzeros; nbits = nbytes * 8; if (nbits > MAX_EXTERN_MPI_BITS) {