From patchwork Mon Feb 5 13:27:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 126883 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1972036ljc; Mon, 5 Feb 2018 05:29:12 -0800 (PST) X-Google-Smtp-Source: AH8x224EBzBBtWsYjWaS/OI5+RgfWyVfROgYj4rT3RkRRIO6NtY44dKtiVkjkGhARjIoEWQpbMnN X-Received: by 2002:a17:902:bf0a:: with SMTP id bi10-v6mr37734905plb.181.1517837352832; Mon, 05 Feb 2018 05:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517837352; cv=none; d=google.com; s=arc-20160816; b=Kybi9C+yk9NY5klCaVVnzDzgPcilgi4Vqn5e8lEyWVk+7TOwoj9No+LJT3nibaocqh 3XDx1YiQ07Ap2mYFJTH9tSOiVbgf7CftFGEnxI/JmottCqDEnHaeA7Tinm9Ni3NRWAGl /wcVfcHN6GWBX+UNPO7xitmbVd401W3CR6QH8TszGVO/DazwVFWiCEAEJLa3MJ4RWlJR NOhLTeDIrd1x5ECim9UmXH0FkRGQBadSUKpdenFy1o/m+3w/2tR8ktitmjRbGh37CnE+ USuYnGP4GcRZBTfCH8Y/F8cfUrHWCx1q87K9Mdor1jyO2P3OL0xvcRubMUMjTKHq916d +O7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=lcS1AVChHbUkNIWtpnKyeCRZQIZa+rM/3AlO26yW3OM=; b=kFEI111d/VmCjKxYUB4lEWc5ymx9raZVOa6jWaYBlqb5sIyVMg2lCZr/zTPchtkV+2 YDTWRzEaee7sADGN7l+7pJCO48YbBXjqBoZKx2mp3TiJm+08tTsOVYn3J1nta9jKwHWb A7BXFPU3+qX9kGs/tWjMg+5ZPRP6JXdMD0kd3M07Pv4f+VjjyqARmHZGzUSu1RY29n4n TmLwT+zWUK/aU7sl94s0TTj88XRLYUyM6v9Oh9kb+eOqR39M5OZH4adbJoP140QbeBa7 6X84250QZM3ZtrRY1aWJqWA9p5WcpxfopXTAUaxCkNnEZrxrVfPpfMppu/pNp8QMKA1D fU9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PLEksQhS; spf=pass (google.com: domain of libc-alpha-return-89972-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89972-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d123si5070723pfg.188.2018.02.05.05.29.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 05:29:12 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89972-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PLEksQhS; spf=pass (google.com: domain of libc-alpha-return-89972-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89972-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=cS8pdGqHiRbBt9igY7XO2eF1IlwSjGU 8cMqcz33DokFyQtxEvXaR33D+cX7aI48rXf5ZJmsUlecphB9Ggqk8QKYUPrzxtIC nAP/TALw93yPVdO9rDDQyXiiJqKX3EnWL56Gt6GZXs1P/W213ydYbnrqOHwkev2a 7vv0MYSHX+ww= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=oxyXbVmL+iymcqZfy8R2bFWJmO4=; b=PLEks QhSNRSt5TVw4t4rSBWG7Mon4J7rZMDyCnsnPCWNtEyg60rnoNdqmnhRlotHIFalk xJ8OHArY5pkCvHSlb9d/5p5e8dF+um9sJ/qmOoVCdFIXDb913ATCWL8ezcKf7+S3 pI/6tT+KXJ+UinftWVs101aWJVTB9p5CMWqr04= Received: (qmail 33522 invoked by alias); 5 Feb 2018 13:27:57 -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 33403 invoked by uid 89); 5 Feb 2018 13:27:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, 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=11917 X-HELO: mail-qt0-f195.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=lcS1AVChHbUkNIWtpnKyeCRZQIZa+rM/3AlO26yW3OM=; b=IsK3dbC/JigoK44cannhNv7ohr0RQ6xEAWy/Vo1PYUKksiKdtXiCZfiq5VsnK9zvUD iqR3ns52q9UseQfNjVzIyLQOBeBikIh6oFHFEKlnswWCLWKNkmPJ6PfXxNsunnDhrJrl vgfVeRIMO811cRqyWPWeTpR00kvR8tmg5ZaZcxzkacmuryWLSMkrUlHTDaoe7Rr85UH7 ixYjX0+KTOXRL2ec5Vi4HlswJ5Z2r9PQSOs03SW3bal2SeHkrz8N2K3bxYCy1x79L4Jg B5QzUkaqsmH0Vh7jU0V1peNiS0pEqnyKWSf8wtdQ0MKWvwlyCu17K16BpV5L9wDuuNV5 Gu4A== X-Gm-Message-State: APf1xPDdw6D/2272+CmI2lkjrDqFaC85k/GZSdl89MMB9EEpFO5hApsm ia/ezJweeehIPJN+qYKBV0gLjW8SRh8= X-Received: by 10.200.36.37 with SMTP id c34mr1708233qtc.253.1517837272681; Mon, 05 Feb 2018 05:27:52 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 08/12] posix: Remove all alloca usage in glob Date: Mon, 5 Feb 2018 11:27:30 -0200 Message-Id: <1517837254-19399-9-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1517837254-19399-1-git-send-email-adhemerval.zanella@linaro.org> References: <1517837254-19399-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, glob): Remove alloca_used argument. Signed-off-by: Adhemerval Zanella --- ChangeLog | 2 ++ posix/glob.c | 25 ++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/posix/glob.c b/posix/glob.c index a78718d..118fcf5 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -32,7 +32,6 @@ #ifndef WINDOWS32 # include -# include #endif #include @@ -65,9 +64,6 @@ # define __stat64(fname, buf) stat (fname, buf) # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) # define struct_stat64 struct stat -# ifndef __MVS__ -# define __alloca alloca -# endif # define __readdir readdir # define COMPILE_GLOB64 #endif /* _LIBC */ @@ -174,12 +170,6 @@ 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 @@ -207,7 +197,7 @@ glob_lstat (glob_t *pglob, int flags, const char *fullname) 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); static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; @@ -273,7 +263,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) @@ -520,11 +509,13 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), char *drive_spec; ++dirlen; - drive_spec = __alloca (dirlen + 1); + drive_spec = malloc (dirlen + 1); *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ - if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) + int r = __glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)); + free (drive_spec); + if (r != 0) { retval = GLOB_NOMATCH; goto out; @@ -921,7 +912,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; @@ -1026,7 +1017,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 @@ -1191,7 +1182,7 @@ struct globnames_result 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) { void *stream = NULL; struct globnames_array globnames;