Re: [PATCH] add u64 number parser

2016-08-11 Thread Christoph Hellwig
On Sat, Jul 23, 2016 at 08:52:18AM -0700, James Smart wrote: > > 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); > > > +

Re: [PATCH] add u64 number parser

2016-07-23 Thread James Smart
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

Re: [PATCH] add u64 number parser

2016-07-23 Thread Alexey Dobriyan
> + ret = kstrtoull(buf, base, &val); > + if (!ret) > + *result = val; Simply pass "result" directly to kstrtoull(). It will not write the result in case of error.

Re: [PATCH] add u64 number parser

2016-07-22 Thread Bart Van Assche
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 kasp

[PATCH] add u64 number parser

2016-07-22 Thread James Smart
add u64 number parser Will be used by the nvme-fabrics FC transport in parsing options Signed-off-by: James Smart --- include/linux/parser.h | 1 + lib/parser.c | 47 +++ 2 files changed, 48 insertions(+) diff --git a/include/linux/parser