From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BBEAC433E0 for ; Sat, 27 Jun 2020 07:28:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CD932088E for ; Sat, 27 Jun 2020 07:28: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="Hmv49r3C" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726394AbgF0H1r (ORCPT ); Sat, 27 Jun 2020 03:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbgF0H1p (ORCPT ); Sat, 27 Jun 2020 03:27:45 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2715DC03E979; Sat, 27 Jun 2020 00:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=Hmv49r3CEmsDSDP480cNnzfK7w M3s1BcGA2mZQSaWszed4Or9AOiEvLo8iLCVA3H3ujoq11ZE2F99oFhzdrm//HZOUjmgSMMBeGtDL1 7s4Kzo7/uoC3XaP+SzZEOcJKGplMLmqVKpk4aca1P7/gqFa+WORKj4gGb/NPXrZq+xS9QnikFae3r mQO19SpH9RxLFYE9PXwB3oebJuuv96VGrSxqqxREQDu/tieO9Xbo2JhxReFnbbjdoAK9oKyYnaalL SS6ASKKcYEsdBf+vdTxbvasr8eRWFmEeqzzVzuSsv/Eset4BUpWV5lzPXVIwRvWHCPpQ1vnzNIiTq dcPumu1w==; Received: from [2001:4bb8:184:76e3:595:ba65:ae56:65a6] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jp5FD-0006X9-8n; Sat, 27 Jun 2020 07:27:24 +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/5] exec: cleanup the count() function Date: Sat, 27 Jun 2020 09:27:02 +0200 Message-Id: <20200627072704.2447163-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200627072704.2447163-1-hch@lst.de> References: <20200627072704.2447163-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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; -- 2.26.2