From patchwork Fri Aug 11 14:50:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 22092 Received: (qmail 79189 invoked by alias); 11 Aug 2017 14:51:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78261 invoked by uid 89); 11 Aug 2017 14:51:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2615 X-HELO: mail-qk0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=dt21c5CGf3bNqjWbUByClu6rKWzsNKlRGgt0P4ZNXP8=; b=BVWDFWT+OljmHSso14bjjOTGZTgD9FQNaRV8zHsrv2QJ6C3aHavg4nHFlHngedtGOw f5S18B3kVFcs2ku2VbUDqnwaMQKNgW19+u1LheJWwrOPfdiDd6EXQuknPJOht7NQ0uVg ISq0NgI28L0tNCFmc7smRH05of/G1Lv5yg9EF+Td9z8bvWqSHqNPRg4c1ygdErB9GueS OeO/hscNp8343rJ50wF2pAF/XM5Gjtt9Sn1PJS+0O+te6FVlswWqWEdP+6nRa/ayMcTj pPMPySs3lERPtW+hqOY59qbmn2CKkxaLL5plKGyQhOzv7WRj3wu/JSw32gjCDhZsyAip 2wxA== X-Gm-Message-State: AHYfb5hxd6yGb2O6zz8T7FoulNNbtt7Zz6PhdIV+OEXik87Y6EYwPKJf OIO4nIfK3pxZcCEsdHmHfw== X-Received: by 10.55.16.161 with SMTP id 33mr20386638qkq.312.1502463068219; Fri, 11 Aug 2017 07:51:08 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 13/18] posix: Remove all alloca usage in glob Date: Fri, 11 Aug 2017 11:50:39 -0300 Message-Id: <1502463044-4042-14-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1502463044-4042-1-git-send-email-adhemerval.zanella@linaro.org> References: <1502463044-4042-1-git-send-email-adhemerval.zanella@linaro.org> With alloca usage removal from glob this patch wraps it up by removing all the alloca defines and macros usage. Checked on x86_64-linux-gnu. posix/glob.c (glob_in_dir): Remove alloca_used argument. (glob): Remove alloca_used. --- posix/glob.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/posix/glob.c b/posix/glob.c index f40ee6d..67196fd 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -59,7 +59,6 @@ #include #include #include -#include #ifdef _LIBC # undef strdup @@ -230,17 +229,11 @@ convert_dirent64 (const struct dirent64 *source) # ifdef GNULIB_defined_closedir # undef closedir # endif - -/* Just use malloc. */ -# define __libc_use_alloca(n) false -# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0) -# define extend_alloca_account(buf, len, newlen, avar) \ - ((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0) #endif static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), - glob_t *pglob, size_t alloca_used); + glob_t *pglob); extern int __glob_pattern_type (const char *pattern, int quote) attribute_hidden; @@ -296,7 +289,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), bool dirname_modified; glob_t dirs; int retval = 0; - size_t alloca_used = 0; struct char_array dirname; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) @@ -974,7 +966,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) & ~(GLOB_NOCHECK | GLOB_NOMAGIC)), - errfunc, pglob, alloca_used); + errfunc, pglob); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; @@ -1081,7 +1073,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (dirname_modified) flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); status = glob_in_dir (filename, char_array_str (&dirname), flags, - errfunc, pglob, alloca_used); + errfunc, pglob); if (status != 0) { if (status == GLOB_NOMATCH && flags != orig_flags @@ -1258,8 +1250,7 @@ struct globnames_result The GLOB_APPEND flag is assumed to be set (always appends). */ static int glob_in_dir (const char *pattern, const char *directory, int flags, - int (*errfunc) (const char *, int), - glob_t *pglob, size_t alloca_used) + int (*errfunc) (const char *, int), glob_t *pglob) { void *stream = NULL; struct globnames_array globnames;