From patchwork Fri Jul 6 19:31:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eldad Zack X-Patchwork-Id: 1167181 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 56BA83FC2A for ; Fri, 6 Jul 2012 19:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752690Ab2GFTcn (ORCPT ); Fri, 6 Jul 2012 15:32:43 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:34804 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757989Ab2GFTck (ORCPT ); Fri, 6 Jul 2012 15:32:40 -0400 Received: by mail-bk0-f46.google.com with SMTP id j10so4699647bkw.19 for ; Fri, 06 Jul 2012 12:32:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=2hvH6WWDXsZmd9KSjvG6GykDOuunptyImXQGxUPe61M=; b=K8ZHbMMAaM7NBWRmlDGKoOKdN6PupeUlK+BKk+ibTZbLXa9c8A3lrZN0B4CIEaWx6F agXMdRHZ6gOsyzzOfuqFamOGwELDcgiwFCC7CiAw3PvLUcJj4HU6XdpX/feVhsus1cM7 Gptd8iB7ikeVSlPs8lWAHynnB1fkhuJ6ZNgwWJgpHnBy1t7ypl6DBazt6lbyNH621xwW 1e9LXiblQ0OADfzl5zYVpW9Gx/XugntjwnEEAiqGog0JAKbg2lObFE7s7gFvzC7bLELH JgtmIlzMlneX7+nHjqORC5FLyoZ0zHtl0MsxeKAI66odEizuBAh8OsqOqIbwAktW+Jcc C8bA== Received: by 10.204.130.89 with SMTP id r25mr15890109bks.48.1341603159749; Fri, 06 Jul 2012 12:32:39 -0700 (PDT) Received: from localhost (p5DDC5275.dip.t-dialin.net. [93.220.82.117]) by mx.google.com with ESMTPS id hs2sm22802533bkc.1.2012.07.06.12.32.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 Jul 2012 12:32:31 -0700 (PDT) From: Eldad Zack To: "J. Bruce Fields" , Trond Myklebust Cc: Joe Perches , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Eldad Zack Subject: [PATCH 2/2,resend] sunrpc/cache.h: replace simple_strtoul Date: Fri, 6 Jul 2012 21:31:57 +0200 Message-Id: <1341603117-13064-2-git-send-email-eldad@fogrefinery.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1341603117-13064-1-git-send-email-eldad@fogrefinery.com> References: <1341603117-13064-1-git-send-email-eldad@fogrefinery.com> X-Gm-Message-State: ALoCoQm9WeIjo4ZpuDks2tOecQQGSSruYrmGe86j9EMgAP8uwrJkfIq5fWOu3I+TTcZlGaRhunbf Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This patch replaces the usage of simple_strtoul with kstrtoint in get_int(), since the simple_str* family doesn't account for overflow and is deprecated. Also, in this specific case, the long from strtol is silently converted to an int by the caller. As Joe Perches suggested, this patch also removes the redundant temporary variable rv, since kstrtoint() will not write to anint unless it's successful. Cc: Joe Perches Signed-off-by: Eldad Zack --- Resent to include improvements from Joe Perches and proper changelog as J. Bruce Fields kindly pointed out. include/linux/sunrpc/cache.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index 6def1f6..af42596 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -217,8 +217,6 @@ extern int qword_get(char **bpp, char *dest, int bufsize); static inline int get_int(char **bpp, int *anint) { char buf[50]; - char *ep; - int rv; int len = qword_get(bpp, buf, sizeof(buf)); if (len < 0) @@ -226,11 +224,9 @@ static inline int get_int(char **bpp, int *anint) if (len == 0) return -ENOENT; - rv = simple_strtol(buf, &ep, 0); - if (*ep) + if (kstrtoint(buf, 0, anint)) return -EINVAL; - *anint = rv; return 0; }