From patchwork Mon Mar 21 13:26:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolai Stange X-Patchwork-Id: 8632931 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 20176C0553 for ; Mon, 21 Mar 2016 13:27:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 574FD20304 for ; Mon, 21 Mar 2016 13:27:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 677DF20320 for ; Mon, 21 Mar 2016 13:27:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755985AbcCUN0x (ORCPT ); Mon, 21 Mar 2016 09:26:53 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33510 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755888AbcCUN0s (ORCPT ); Mon, 21 Mar 2016 09:26:48 -0400 Received: by mail-wm0-f65.google.com with SMTP id x188so21825460wmg.0; Mon, 21 Mar 2016 06:26:47 -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=AhOM27IW4lZMesI4XRjItdKnJ0K7LULUV7UMRPtLbaA=; b=A8LCG+yOugjBJJ4WAnUYNKsxnyzZ7eNC+TvV/WhvORt9Bja4gA/oMQ9tZlJTiKGpw7 xjxF0QZfTvGkOAq1aDucHOg0hqu4CRxuq1h6Msg9+RF73aVDwRpDJO8iZBQcJVPv9dU1 8g/u0dyDtCiDloIddt4MfDd8Uivtt1YOd7FU6bNHKbbyhZxmwYjomazUZkvx3JYNrPrX em+MOJzi6M4GmAKFHHSJperdrhVSyU7TAoKSgh3mMQF2ofyge6UYajIwElNgFPZ9yrs2 AbgPAiWaa5Y2AzUX1BPYgTcXfVbmn+6fK9iqdM9MiQ3PH4yuPXAhpq6pUAdcqAtF1kIw 0VnQ== 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=AhOM27IW4lZMesI4XRjItdKnJ0K7LULUV7UMRPtLbaA=; b=ClZqOpsI0k4DVEpuPLDfJXJ5i1l04w2HwZKX/Vwg0XljnTSWZiTjPS+ZNjifv0K4ah xz81N90dDlap52O+r04I6m88DAtNme0A84gbFm8dmUE6Zk7PTGS7hGWBY6CSYVhdDbLi HHmmWBOPxvGlb+i45f7b6rJZSr3kb0B8Md/uplOuXPGDO/NO4uQIwHF7sorYkVYW34Q1 cd2HJ/KRnmO97RGZGzJ/IqXmDOytJJR7tZqNnpnB2GpqdzG8R/Dtkhswn/bG6AJTkhXg GE7TQld1iAU8cRIuEF9Tenv5uSpHSEZoXjo/8YsDiWNRPPqRiQoVJnSCFWKgI7viRY3N rVZg== X-Gm-Message-State: AD7BkJIZcF8gc+MTd3fka0oT+J7HEourXmu8/bG+R+jx2ymbmUn+4sFpX+z9/5cwijutWQ== X-Received: by 10.28.226.212 with SMTP id z203mr14481883wmg.9.1458566806908; Mon, 21 Mar 2016 06:26:46 -0700 (PDT) Received: from localhost (x55b18fc0.dyn.telefonica.de. [85.177.143.192]) by smtp.gmail.com with ESMTPSA id fv6sm25409801wjc.12.2016.03.21.06.26.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Mar 2016 06:26:46 -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 09/14] lib/mpi: mpi_read_raw_from_sgl(): replace len argument by nbytes Date: Mon, 21 Mar 2016 14:26:10 +0100 Message-Id: <1458566775-5239-10-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 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 27582e2..2de2c7d 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) {