Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1160431ybp; Fri, 11 Oct 2019 09:49:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ2oF81NRTBGhdSo5ievwBWHT83zx6I6uPenYfrBNdECcmGk+EPZWFeUH8oZvw2zPU0IbE X-Received: by 2002:a50:fc9a:: with SMTP id f26mr14338866edq.217.1570812598368; Fri, 11 Oct 2019 09:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570812598; cv=none; d=google.com; s=arc-20160816; b=Cy+mY7yhMcLrWvj7ZbC6nCyhKrSgZiWOzPIqisY7w5g6azPTmueDAbkzyitaHVPi1M yJKjiSpApxJ9IpVeEb8egf4BU+f43msZ7fnGewfiRInoA2nHY1uA9jdXbpSnPyeRzJAi 2w7QSeQP9ZG/N467MCISlsx714wSEkoSi5L2AWduuAoKv4FqbyEe8blCZuGUohN6QBwR +pCvwFFM3cTcqeJnhwP3kGhVv3gKPZCNiD5gIM5RVd9Ilm6vE3tlqP+fQf3wP7ca3VRH qfcYfU2pUSND7a0zFAVH8IbEiaR9WHE46cnYEY4dah0wB56vJJ2eV3PfaUGBYofOMAwl 1U0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nuozGlG7HQkwnD6M6LPAmMN7UWNJFU2pedx0OePfc18=; b=lKs0aNRRuBednmk+F2EbKDwhzHnSVEyv1BgBO1io2ACFcsjNypoxE9PVw4DWaEV3os CewT7XpmcBmq/rtgRpAcQ1ZJhopkEzGhEjGGe7MRsMSJOuzlAswGRLWHLlCIktCS4Wxb 6bERdNiDRBSKgVi0gPfk0zehQs3ic++Ttm+iTTd/a+YpUx/VlaXi226U0Bc7APrX0Nxz 4OaWp+R+celHvVgT/o14t3uBcBrgcLBJ14EOKocPBaUarVFdw4xSpcQ47Z5xMUM9O8Uw T4sLlv/6JeEr4J4I+YLzwVrXPMil/ptK5X0oi7YNMMY8kQt+06dLdzi7d4xRkLYYcTuu f1Xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si7174632eda.8.2019.10.11.09.49.33; Fri, 11 Oct 2019 09:49:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbfJKQt2 (ORCPT + 99 others); Fri, 11 Oct 2019 12:49:28 -0400 Received: from fieldses.org ([173.255.197.46]:59046 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbfJKQt2 (ORCPT ); Fri, 11 Oct 2019 12:49:28 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 4A6351C97; Fri, 11 Oct 2019 12:49:28 -0400 (EDT) Date: Fri, 11 Oct 2019 12:49:28 -0400 From: "J. Bruce Fields" To: Andy Shevchenko Cc: Chuck Lever , linux-nfs@vger.kernel.org Subject: Re: [PATCH v1] nfsd: remove private bin2hex implementation Message-ID: <20191011164928.GC19318@fieldses.org> References: <20191011160258.8562-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191011160258.8562-1-andriy.shevchenko@linux.intel.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Thanks, applying.--b. On Fri, Oct 11, 2019 at 07:02:58PM +0300, Andy Shevchenko wrote: > Calling sprintf in a loop is not very efficient, and in any case, > we already have an implementation of bin-to-hex conversion in lib/ > which we might as well use. > > Note that original code used to nul-terminate the destination while > bin2hex doesn't. That's why replace kmalloc() with kzalloc(). > > Signed-off-by: Andy Shevchenko > --- > fs/nfsd/nfs4recover.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c > index cdc75ad4438b..29dff4c6e752 100644 > --- a/fs/nfsd/nfs4recover.c > +++ b/fs/nfsd/nfs4recover.c > @@ -1850,19 +1850,14 @@ nfsd4_umh_cltrack_upcall(char *cmd, char *arg, char *env0, char *env1) > static char * > bin_to_hex_dup(const unsigned char *src, int srclen) > { > - int i; > - char *buf, *hex; > + char *buf; > > /* +1 for terminating NULL */ > - buf = kmalloc((srclen * 2) + 1, GFP_KERNEL); > + buf = kzalloc((srclen * 2) + 1, GFP_KERNEL); > if (!buf) > return buf; > > - hex = buf; > - for (i = 0; i < srclen; i++) { > - sprintf(hex, "%2.2x", *src++); > - hex += 2; > - } > + bin2hex(buf, src, srclen); > return buf; > } > > -- > 2.23.0