From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751303AbcGWPwZ (ORCPT ); Sat, 23 Jul 2016 11:52:25 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:33727 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751075AbcGWPwT (ORCPT ); Sat, 23 Jul 2016 11:52:19 -0400 Subject: Re: [PATCH] add u64 number parser To: Bart Van Assche , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org References: <5792b919.0C1gyf+dF4XKu6Zj%james.smart@broadcom.com> <5e325cbb-a140-8f26-7402-5dc1a2cd07ea@sandisk.com> From: James Smart Message-ID: <09649a75-e9a1-11d7-37e2-48f4e93a3b2e@broadcom.com> Date: Sat, 23 Jul 2016 08:52:18 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <5e325cbb-a140-8f26-7402-5dc1a2cd07ea@sandisk.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/22/2016 6:32 PM, Bart Van Assche wrote: > On 07/22/16 17:23, James Smart wrote: >> + buf = kmalloc(len + 1, GFP_KERNEL); >> + if (!buf) >> + return -ENOMEM; >> + memcpy(buf, s->from, len); >> + buf[len] = '\0'; > > Hello James, > > Have you considered to combine the above kmalloc() and memcpy() calls > into a single kasprintf(GFP_KERNEL, "%.*s", len, s->from) call? > > Bart. > No, I followed the example of existing parse functions in the file. -- james