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: 11612417 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 A1C8F618 for ; Thu, 18 Jun 2020 14:47:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EE4020897 for ; Thu, 18 Jun 2020 14:47:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CsnAe1h7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EE4020897 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zib1PnPStHBahE8NRb7E8QgnHvp416ZZQzYPGaHhnyk=; b=CsnAe1h7x5us6E SKofyn+wgI4/R7nOc2Xf3Zs+CLI4HA/wjyneBqbsXcHAxLCIXL+y1ykydmVzSzjiTd6qSPyvJpXrV BI4JTCSBQALPLh8dxAnfsgEX1ahRWIasrHYt+ekX93MWC0euNkl9Tz9O39ox/casToBDYVNU0cUvM xXzcme+6nRMd+aEVHzD+0x+OzvEXz6BMVoCmldHLJp6IONAvM/WD3rN/dSlqE5BLVbKqHziyVcYXb hUJV1ulHn+sONpBylZA3CmtqRmcicGyKuADS5/suhMKyperTiRwi1J4COQoXBoyK4Code1gDyI6+H I2y5/5LxR18ThlJSedjw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlvpE-00077t-TF; Thu, 18 Jun 2020 14:47:32 +0000 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 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-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, Arnd Bergmann , Brian Gerst , x86@kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Luis Chamberlain , sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;