Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1069653iof; Mon, 6 Jun 2022 19:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTIwhSMzJwp9S+2Dtjg2VfIamIsBoGilUYMWyEH4OmzGZg/pQvKShmjNWezan9pRSMuq66 X-Received: by 2002:a17:907:7b86:b0:711:d2c8:ab18 with SMTP id ne6-20020a1709077b8600b00711d2c8ab18mr6148594ejc.580.1654570212224; Mon, 06 Jun 2022 19:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654570212; cv=none; d=google.com; s=arc-20160816; b=KWGkEzEu5L1Lzbjb9PS9xiT5tVgHQ/GXtYGCkpBzmqKZM2MECCYT5PBpph4iY+sxFy YhwEuECED5rWbE3wDwSix5cEVt+CzZvh98aWSnUe2VCyYOJQNh970IV/UVDN1pxm0w1A Yj8D3xnDPx7nzyHRRrWuqePgpMHOhXFTzZKzwLCOizOy6xbkRLpm8C9TAm/2Zzj+L8d9 9qulLsFCJzVSmnO+lyvBfAolvQQsthrmRp9YUmribUkoKAx+27aDtAZXmfPjHPeYCPjk MSCoSvkMOmbaXHhuVMKorI511mCaXTeaJfLbnE6K3leDJc8HL/jEbL5vc6odXepyA2Rs rgYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=OUqKl01D1Dk9739cP4y1+EH2QYoOpo0/Xdt7m0JZ3fg=; b=GNYeYmdMeY4GiW1Xcw3c7ZAJ4zTZT9gDn3fNQ7N+VW42Q/CdiJx9nssY/M8AHY79fc 1nSuGtAsjgtKaVaxoOLUxIdCfSU2wQbjuEGa9ZTzHtD48nvG17Lwdgnuxr7jSaShm4Hl U3G8qyzbpV85KeZEvh7ow1QCOhfvcXnYw0nTbc9f0FdXKl1xe4OWlI+pmLCkqHqkmmG6 cNMwIrMCsmya3U2szWrFSgSVALXzlxtgOxQA2gDbsK7Zb8ET4YmgHZ91X+uMiWkDT0J3 Ob63gSpQglDhVt8+aNI/S5OHENcN7Z6uMtLtru/8p823opsAab2/OAWCPVIdpS1Xt+a3 CjOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=xAYe1wvT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=etKUuENP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf2-20020a1709077f0200b006fef31e2902si12662547ejc.972.2022.06.06.19.49.45; Mon, 06 Jun 2022 19:50:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@suse.de header.s=susede2_rsa header.b=xAYe1wvT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=etKUuENP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236004AbiFGCiK (ORCPT + 99 others); Mon, 6 Jun 2022 22:38:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbiFGCiJ (ORCPT ); Mon, 6 Jun 2022 22:38:09 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5FBE5F8D9 for ; Mon, 6 Jun 2022 19:38:08 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9829921B59; Tue, 7 Jun 2022 02:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1654569487; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OUqKl01D1Dk9739cP4y1+EH2QYoOpo0/Xdt7m0JZ3fg=; b=xAYe1wvTaSpU4f8aAzBQTIA/tteYlSGAg4X7gIiKv3WlQ8t/fhbXqh9XCPBtiIBuNnG2H1 0to0HvBC+uz68IlqgvsTZSmckqcwV8vzIELZUHkN2WIqqSNs4Pi7g8BO6P/DuwlHPFJ2sI KrUZAgdj2bA5bUi5qVg7RgD4HIIIOj8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1654569487; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OUqKl01D1Dk9739cP4y1+EH2QYoOpo0/Xdt7m0JZ3fg=; b=etKUuENPrTzV3eLJrhmdLdSZEFVQT5NPGXImeEA7KOThoD6be+xrUtra25jQnDZ+uCgp/M lWY2lxhjbqXcdaDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B9F7613A15; Tue, 7 Jun 2022 02:38:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XkbNHA66nmLCKgAAMHmgww (envelope-from ); Tue, 07 Jun 2022 02:38:06 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" Cc: "Linux NFS Mailing List" Subject: Re: [PATCH v1 3/5] SUNRPC: Clean up xdr_commit_encode() In-reply-to: References: <165445865736.1664.4497130284832282034.stgit@bazille.1015granger.net>, <165445911819.1664.8436212544546306528.stgit@bazille.1015granger.net>, <165456394819.22243.15333379326870400835@noble.neil.brown.name>, Date: Tue, 07 Jun 2022 12:37:58 +1000 Message-id: <165456947808.22243.6052931047455826981@noble.neil.brown.name> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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-nfs@vger.kernel.org On Tue, 07 Jun 2022, Chuck Lever III wrote: > > > On Jun 6, 2022, at 9:05 PM, NeilBrown wrote: > > > > On Mon, 06 Jun 2022, Chuck Lever wrote: > >> Both the ::iov_len field and the third parameter of memcpy() and > >> memmove() are size_t. There's no reason for the implicit conversion > >> from size_t to int and back. Change the type of @shift to make the > >> code easier to read and understand. > > > > I wouldn't object to "shift" being renamed "frag1bytes" to make the > > connection with xdr_get_next_encode_buffer() more blatant.. > > I thought of that. Readers would wonder why frag1bytes in > xdr_commit_encode() was a size_t, but in xdr_get_next_encode_buffer() > it's a signed int. It started to become a longer string to pull. > Maybe it's worth it? > Probably worth it. Not necessarily worth it today. I have no strong preference. NeilBrown > > > Reviewed-by: NeilBrown > > > > Thanks, > > NeilBrown > > > > > >> > >> Signed-off-by: Chuck Lever > >> --- > >> net/sunrpc/xdr.c | 4 +++- > >> 1 file changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c > >> index 08a85375b311..de8f71468637 100644 > >> --- a/net/sunrpc/xdr.c > >> +++ b/net/sunrpc/xdr.c > >> @@ -933,14 +933,16 @@ EXPORT_SYMBOL_GPL(xdr_init_encode); > >> */ > >> inline void xdr_commit_encode(struct xdr_stream *xdr) > >> { > >> - int shift = xdr->scratch.iov_len; > >> + size_t shift = xdr->scratch.iov_len; > >> void *page; > >> > >> if (shift == 0) > >> return; > >> + > >> page = page_address(*xdr->page_ptr); > >> memcpy(xdr->scratch.iov_base, page, shift); > >> memmove(page, page + shift, (void *)xdr->p - page); > >> + > >> xdr_reset_scratch_buffer(xdr); > >> } > >> EXPORT_SYMBOL_GPL(xdr_commit_encode); > >> > >> > >> > > -- > Chuck Lever > > > >