Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754829AbbBTWcJ (ORCPT ); Fri, 20 Feb 2015 17:32:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44871 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754537AbbBTWcH (ORCPT ); Fri, 20 Feb 2015 17:32:07 -0500 Date: Fri, 20 Feb 2015 14:32:05 -0800 From: Andrew Morton To: Ameen Ali Cc: linux-kernel@vger.kernel.org, Ameen Ali Subject: Re: [PATCH 2/2] staging: replace simple_strtoul with kstroul Message-Id: <20150220143205.a7d70f9bfc422995ba8fb909@linux-foundation.org> In-Reply-To: <1424384037-4081-1-git-send-email-ameenali023@gmail.com> References: <1424384037-4081-1-git-send-email-ameenali023@gmail.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1605 Lines: 49 On Fri, 20 Feb 2015 00:13:57 +0200 Ameen Ali wrote: > Subject: [PATCH 2/2] staging: replace simple_strtoul with kstroul This isn't a staging patch. s/kstroul/kstrtoul/ > Date: Fri, 20 Feb 2015 00:13:57 +0200 > X-Mailer: git-send-email 2.1.0 > > Replacing obsolete simple_stroul with kstroul s/kstroul/kstrtoul/ > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -518,7 +518,7 @@ struct devkmsg_user { > static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) > { > char *buf, *line; > - int i; > + unsigned long int i; It would be better to move this definition so it is local to the `if' loop where it is used. And to give it a meaningful name - using `i' is lame. > int level = default_message_loglevel; > int facility = 1; /* LOG_USER */ > size_t len = iocb->ki_nbytes; > @@ -549,7 +549,7 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from) > if (line[0] == '<') { > char *endp = NULL; > > - i = simple_strtoul(line+1, &endp, 10); > + i = kstrtoul(line+1,10, &endp); > if (endp && endp[0] == '>') { > level = i & 7; > if (i >> 3) The interfaces are different - kstrtoul() can return a negative errno. afaict we'll only have issues if someone tried to print "<>..", but this string is coming from userspace so we must be very paranoid. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/