Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7081184rwd; Tue, 6 Jun 2023 06:12:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6iDr7ef6/khcfxevlffCdquZhjVMPwt6I+bUhFNhKL71Xvks2z1dHMy0REcXBMxiZ1krpV X-Received: by 2002:a05:6214:5193:b0:625:8684:33f3 with SMTP id kl19-20020a056214519300b00625868433f3mr2258130qvb.0.1686057143933; Tue, 06 Jun 2023 06:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686057143; cv=none; d=google.com; s=arc-20160816; b=UTsjXJMOyVUseHV8eQpYTPKo51AMC3I8Rhm9y0ej33wyAiuyhoIaODurKVsMYHTT5q lmNZbiDH4ECh/TtxTRYInGdhVVc9JGcgIHOkxei5GduSohbWZH7CNpusYiPVTBEEPsYf uNQyVwKMntPXRQ5KPzMjAn3EPaoI6+CuNg0nwLw5D+625WeT1URn6CGqyMeeun/tKXFK Zci4WC3lfXGBSSDQ1fQZLk6fUyhJOPJXF+RTdXF5x2iCohcPNyLD+Adyl91X4uxS/9jZ iseP1IBkK81MNhDBoT6RnH6ErcDyWPo+IwWmQS0BJqeqnx9nejT08ktZbhciKQGsoHp8 zJGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jD4W/W7iXB9ATeRl2QuO5GnCDoE2m4ZXOMCYUAgCXGY=; b=Xbl4cONILVQXxK8BrLx6sXSrLSzKFaMk1jriUfdYhOVuEfO791le9x6Aaugprc57fS wNVCjDMK6FpyZ5PoRofzYsidEx1a14XmtWZtC/EdAywM3gQofiyd3G3xaHvnX9nCs/Ce 3C/v1fVG7AXgLC35IjFDiI9l0OMbxEDJPX1P75n1jyQebJRT/QjW/ugY4d9+cf1k/6fh ke3YvUjSd/xAqnirEBsvhBOJ43vwI44X7uapTEIg2oCvXLkPezoACehE/iQn4euF1VvE UhfPhQzHHjysS329LTE2a/XxPr/Bql+k7z+VIZB0r4keM/PAZvI9RvZJtZeeW8A8+27L dvxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARcMw1Qw; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x6-20020a05622a000600b003f956866873si2885492qtw.212.2023.06.06.06.12.03; Tue, 06 Jun 2023 06:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARcMw1Qw; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238195AbjFFNLc (ORCPT + 99 others); Tue, 6 Jun 2023 09:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238191AbjFFNLJ (ORCPT ); Tue, 6 Jun 2023 09:11:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A027410F1 for ; Tue, 6 Jun 2023 06:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686056979; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jD4W/W7iXB9ATeRl2QuO5GnCDoE2m4ZXOMCYUAgCXGY=; b=ARcMw1QwxDMiJ0Wg8UQU800e8t/ta95t6M7hKZT8/I2pK5XQX3UL8CnaDqng9sj0zi9UD+ v6PZU0VIJjMxhWinKY9+cRbpg15264wHSKNdLBV3AB7OlEJqxuYYrnZq4vpdM0sFDpjeg9 qkuPIlqGlvIbUxCnCRmCECeiPwOASTo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-JFtKf6EgPN2rwQdPKMPv1g-1; Tue, 06 Jun 2023 09:09:35 -0400 X-MC-Unique: JFtKf6EgPN2rwQdPKMPv1g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC95D811E91; Tue, 6 Jun 2023 13:09:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ECF52166B25; Tue, 6 Jun 2023 13:09:31 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Herbert Xu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-crypto@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 07/10] crypto: af_alg: Indent the loop in af_alg_sendmsg() Date: Tue, 6 Jun 2023 14:08:53 +0100 Message-ID: <20230606130856.1970660-8-dhowells@redhat.com> In-Reply-To: <20230606130856.1970660-1-dhowells@redhat.com> References: <20230606130856.1970660-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Put the loop in af_alg_sendmsg() into an if-statement to indent it to make the next patch easier to review as that will add another branch to handle MSG_SPLICE_PAGES to the if-statement. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- Notes: ver #2) - Fix a checkpatch warning. crypto/af_alg.c | 51 ++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index b8bf6d8525ba..fd56ccff6fed 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1030,35 +1030,38 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, if (sgl->cur) sg_unmark_end(sg + sgl->cur - 1); - do { - struct page *pg; - unsigned int i = sgl->cur; + if (1 /* TODO check MSG_SPLICE_PAGES */) { + do { + struct page *pg; + unsigned int i = sgl->cur; - plen = min_t(size_t, len, PAGE_SIZE); + plen = min_t(size_t, len, PAGE_SIZE); - pg = alloc_page(GFP_KERNEL); - if (!pg) { - err = -ENOMEM; - goto unlock; - } + pg = alloc_page(GFP_KERNEL); + if (!pg) { + err = -ENOMEM; + goto unlock; + } - sg_assign_page(sg + i, pg); + sg_assign_page(sg + i, pg); - err = memcpy_from_msg(page_address(sg_page(sg + i)), - msg, plen); - if (err) { - __free_page(sg_page(sg + i)); - sg_assign_page(sg + i, NULL); - goto unlock; - } + err = memcpy_from_msg( + page_address(sg_page(sg + i)), + msg, plen); + if (err) { + __free_page(sg_page(sg + i)); + sg_assign_page(sg + i, NULL); + goto unlock; + } - sg[i].length = plen; - len -= plen; - ctx->used += plen; - copied += plen; - size -= plen; - sgl->cur++; - } while (len && sgl->cur < MAX_SGL_ENTS); + sg[i].length = plen; + len -= plen; + ctx->used += plen; + copied += plen; + size -= plen; + sgl->cur++; + } while (len && sgl->cur < MAX_SGL_ENTS); + } if (!size) sg_mark_end(sg + sgl->cur - 1);