From patchwork Thu Jun 18 14:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11612399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63E1514E3 for ; Thu, 18 Jun 2020 14:47:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D76E208C3 for ; Thu, 18 Jun 2020 14:47:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="cDsZ1ShF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731262AbgFROq6 (ORCPT ); Thu, 18 Jun 2020 10:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731251AbgFROqr (ORCPT ); Thu, 18 Jun 2020 10:46:47 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EEAFC0613EE; Thu, 18 Jun 2020 07:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=e+EEFqv4wjvmMJMr72kiOJnRNTJBptkSbMiAtyzJmZo=; b=cDsZ1ShFwd9Ln5BPgg8qOv0W/P hlsuMobnYQrnQBJ7zqCS62LwjSfgqRwh7glQ/04WuMjZ1hBXnBRmlpSlSUAkhXm9eT3NKQaTxLT2M iK3SYtvirSW5fOZv2Ij+30m/d+5U6swvPqNt8ZUNEYZjLRHnIC5wMSbVfTZTvF90voUQNNuVaSIBI mhmNsL8B3+XTHQU7hwqmUhhOD7IXQyLKzRs2HWcKi+4qxcbJ3riKiDtHzDC+/3HW4i4ezvFlMxUev dVQwCs3gRjbHOaUOBySXc1oOHBX5wcKN78BBS/HEhi4w+mxTq5IHK00PqfG6GdmT8SJ8WibTjALI/ eTQFA0UQ==; Received: from 195-192-102-148.dyn.cablelink.at ([195.192.102.148] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlvoN-0006OL-B5; Thu, 18 Jun 2020 14:46:40 +0000 From: Christoph Hellwig To: Al Viro Cc: Arnd Bergmann , Brian Gerst , Luis Chamberlain , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] exec: cleanup the count() function Date: Thu, 18 Jun 2020 16:46:24 +0200 Message-Id: <20200618144627.114057-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200618144627.114057-1-hch@lst.de> References: <20200618144627.114057-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Remove the max argument as it is hard wired to MAX_ARG_STRINGS, and give the function a slightly less generic name. Signed-off-by: Christoph Hellwig --- fs/exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 4e5db0e35797a5..a5d91f8b1341d5 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -407,9 +407,9 @@ get_user_arg_ptr(const char __user *const __user *argv, int nr) } /* - * count() counts the number of strings in array ARGV. + * count_strings() counts the number of strings in array ARGV. */ -static int count(const char __user *const __user *argv, int max) +static int count_strings(const char __user *const __user *argv) { int i = 0; @@ -423,7 +423,7 @@ static int count(const char __user *const __user *argv, int max) if (IS_ERR(p)) return -EFAULT; - if (i >= max) + if (i >= MAX_ARG_STRINGS) return -E2BIG; ++i; @@ -441,11 +441,11 @@ static int prepare_arg_pages(struct linux_binprm *bprm, { unsigned long limit, ptr_size; - bprm->argc = count(argv, MAX_ARG_STRINGS); + bprm->argc = count_strings(argv); if (bprm->argc < 0) return bprm->argc; - bprm->envc = count(envp, MAX_ARG_STRINGS); + bprm->envc = count_strings(envp); if (bprm->envc < 0) return bprm->envc;