Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1647721ybt; Mon, 15 Jun 2020 06:04:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC+O2K0IYevcGMtoC2FozIREoPM+WCbADDiwg30uwLIscuF+hcO0yxzuZImyMDZH9sZKAF X-Received: by 2002:a17:907:b03:: with SMTP id h3mr27161075ejl.367.1592226269697; Mon, 15 Jun 2020 06:04:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592226269; cv=none; d=google.com; s=arc-20160816; b=RAoyqzK0Ixz6I8jZgCMUdIQrdkzJ7aogWzoyspJ1aTItMCn+jPz8w+Ytxx7fh+LaGA H/86Xzr/DYmuPgHRL9UJ/cdR4q4ZVvP66ku+3887i/miC7v4o8soJOlukQwXO/Z4lN2i 0ZYguPnB9MRdtPYQFiC3e2EaXH4LY/V0pwWUZD8aQeEMDWQDhNB7HnOKtxRdAJRqgIQv im3sTE/Omj8c9tvaV9eN5Y8gSuo0sUbsfY3Imkq2r+HX7tlt4SKaAFNTMxm073uU4PhS D/CSzg9ljGpWYEmO4XVLvsXpTFTASMmNu27WFuZwcQO2qAUJnL0KiziapuwSe5gJrzNE u+2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SM2vwUzS1lS5JPIE11hnWuY4020BCObQGWMmPP5iv+U=; b=suwUd5++YwCXFV51uETGXK/G4wr+MTC40pcbuwtBhOXHoSiNwUXd6g7DasNwWsrKFX VzFEszrHLeYFCtytP6J51nKZ1t3aPx+JcJtuTKOzlwC0oo8ktTWPqCPVeMukIbNduDpf ARTWdU0hgKR5+W0ehrfDtnXp9AwKFCNT7CcVAWlAhJpCQATtOJOiJFby2RHxLxQUUZDv lSP9+EJpGiVhWSkXuQcl/k8gkurw81DNa+j8TMerJZyC+WVQkyuqVDgmW7MRjUqc+qde EW2m5xXOoj69D7549N23znTwCkvLyvhFNRg84jW8vIK1XRlPIwGgKNx6wYxAl5ooHqfN EWhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IH5rGn9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si8733371ejq.305.2020.06.15.06.04.07; Mon, 15 Jun 2020 06:04:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IH5rGn9P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730129AbgFONCE (ORCPT + 99 others); Mon, 15 Jun 2020 09:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730357AbgFONAx (ORCPT ); Mon, 15 Jun 2020 09:00:53 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAEC7C061A0E; Mon, 15 Jun 2020 06:00:52 -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=SM2vwUzS1lS5JPIE11hnWuY4020BCObQGWMmPP5iv+U=; b=IH5rGn9PdguQ/MJmSQeWa39CS5 xYhYsW2KOhQ7JARWxoLOcrAASLH7Mg9nT9bOWMT2QsLkXgR1PiM53SOGyGhcJ/pOT2uQ2oAoMYCea FMpsAX3009azgrIIbJwwa4ZNiutR+PuL4iA9/LrosE5OcMBEFLoo9a/4A5MCyCVQaW8T31HswmFa0 E+juO8zuJ7Y80JJqixESrR+bfEJ20AqTuLGcZIjJ8Ej5wzqh4V67dC0vKsf1bGZNzGSX+tMr9bm2o d3vFWAelmSJD0mv1AatU2ckIMAIiODHoH1OoVQriwq0EsCjoMCtY8lbWHO55db++0T6OOrImMQcPW J59ZlUjA==; 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 1jkojC-0007sl-3K; Mon, 15 Jun 2020 13:00:42 +0000 From: Christoph Hellwig To: Al Viro Cc: Arnd Bergmann , 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: Mon, 15 Jun 2020 15:00:29 +0200 Message-Id: <20200615130032.931285-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200615130032.931285-1-hch@lst.de> References: <20200615130032.931285-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 94107eceda8a67..6e4d9d1ffa35fa 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -411,9 +411,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; @@ -427,7 +427,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; @@ -445,11 +445,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; -- 2.26.2