From patchwork Tue Jan 5 18:58:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41649 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 609ED393C863; Tue, 5 Jan 2021 18:58:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 609ED393C863 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1609873124; bh=B6ZrpSlZvx9vfcNH+7mP1vKuPEslZb8xuWsu4QeEy9k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tAzH413XFnwImm+JaO2oc+Qb/58zGCwEjeBeuN299gkjvYP5VLDbUpRF3dnqvgz8L kYoLJsBH4CacDtZeQsLqWfG4wE1iiX54mldeQfeIh5oGWXEsIppa2Y4LSj4h/CXfV0 W2BkNstm7cfFORVDlkTp+ul5cszqxehDKY6tOa+Y= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by sourceware.org (Postfix) with ESMTPS id 10211393C84D for ; Tue, 5 Jan 2021 18:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 10211393C84D Received: by mail-qv1-xf2d.google.com with SMTP id az16so142160qvb.5 for ; Tue, 05 Jan 2021 10:58:41 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=B6ZrpSlZvx9vfcNH+7mP1vKuPEslZb8xuWsu4QeEy9k=; b=r179nuCjec6iDq6+nP/1oy0TA+CqCMaAU/3P8UNSxz4nS75cT73l8DYTXCizEo7rea 6E8XSTxHure9bP3cCUNFm/R0Slp/tqkg6SyzBLnMAAJNhK5SJ7MKhsn1SucQ9yS+CJ+9 eNZs8CS8NjhOvO3edN4FzyZo72l2HIPIL9ChYiSmuflebAFfU60tFh9OKhxYusndqYNX 2gM4HelH0qdCU5zseJ1SqnUsJAXcVoTQr7ywhpOE/22tV4gYpdbowPIPBVeDOrSF4+mN 5hXFRDJDERr4KVhmu0wj77KOMkDkqEZ1SGn2+0FIa2qbbQc2DLyrtya382BhdOmCiqNG zocQ== X-Gm-Message-State: AOAM531d+1aHcHi6DgiIXUlcWTa6Qy2Jci4QRXRqTFiIcmsNBACrBthl A5/0Skwks52CrZBBX5PIxb8Tq/T3Q5oJqA== X-Google-Smtp-Source: ABdhPJwJZwn+B2lFDHcLK5tWC6NXbDlPyjg2Z8ueoe11i5lXdK69gcd2uxKNqVwSzrL9//0Pc6WGyA== X-Received: by 2002:ad4:5762:: with SMTP id r2mr550199qvx.45.1609873120265; Tue, 05 Jan 2021 10:58:40 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id t68sm67792qkd.35.2021.01.05.10.58.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 10:58:39 -0800 (PST) To: libc-alpha@sourceware.org, Paul Eggert , bug-gnulib@gnu.org Subject: [PATCH 8/8] posix: Remove all alloca usage in glob Date: Tue, 5 Jan 2021 15:58:20 -0300 Message-Id: <20210105185820.3796657-9-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210105185820.3796657-1-adhemerval.zanella@linaro.org> References: <20210105185820.3796657-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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 | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/posix/glob.c b/posix/glob.c index b6727ee884..c7a89a5298 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -42,7 +42,6 @@ #ifndef WINDOWS32 # include -# include #endif #include @@ -74,7 +73,6 @@ # 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 @@ -184,12 +182,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 @@ -217,7 +209,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; @@ -282,7 +274,6 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), int meta; glob_t dirs; int retval = 0; - size_t alloca_used = 0; struct char_array dirname; bool dirname_modified; @@ -530,11 +521,13 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int), char *drive_spec; ++dirlen; - drive_spec = __alloca (dirlen + 1); + drive_spec = malloca (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; @@ -935,7 +928,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; @@ -1040,7 +1033,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 @@ -1206,7 +1199,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;