From patchwork Thu Jun 8 21:13:28 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: 20866 Received: (qmail 40757 invoked by alias); 8 Jun 2017 21:14:18 -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 40536 invoked by uid 89); 8 Jun 2017 21:14:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qt0-f177.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=UeGAaHlQ3G8+ljnzbv9JSJ5wAho2dk7MQtmFARw9L4w=; b=oNXkNKP+N4ERUPZSV3EVyTpLgWkHUkHqzo5mLpjJJK27KOLjkRL6GSPhy+aGVxtEXp AS1CUp0xkP4d6wmMVBDhk6w7kMZ9f/jeRztmxqjZEi6xX4PKFMVizlWorrdAB6Xa+HgW mTeyQkiUWFSRKQy3QQdOCVMdNHxOA7oSLnzJFcEKwcfAAblidhuwdXYSOiHK9FyMEEsE e19vC+sSGNoROUve3yupi/LYf+JOqITlBCrrHhi+m7rqEWCJvOaYkQMYLSqwTqVqkU77 JAeAcYs8Wgl4xAJBM9y24jyo9Wir7fjiFtj8/hoVs9I70gz1kPmnA1f+qn3cIF7JnfXR pRTQ== X-Gm-Message-State: AKS2vOyDp2gmCm1QKK0ejN1VmsBHjN0EDEXglQKX2NBy4uBFCELAT0zi 1I9MESs5D4jlWz97VcQ9ig== X-Received: by 10.55.92.68 with SMTP id q65mr30392566qkb.205.1496956456790; Thu, 08 Jun 2017 14:14:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 14/17] posix: Remove all alloca usage in glob Date: Thu, 8 Jun 2017 18:13:28 -0300 Message-Id: <1496956411-25594-15-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1496956411-25594-1-git-send-email-adhemerval.zanella@linaro.org> References: <1496956411-25594-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 62be373..652ae9e 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -58,7 +58,6 @@ #include #include #include -#include #ifdef _LIBC # undef strdup @@ -229,17 +228,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; @@ -295,7 +288,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) @@ -972,7 +964,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; @@ -1079,7 +1071,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 @@ -1256,8 +1248,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;