From patchwork Fri Dec 8 09:16:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnold Robbins X-Patchwork-Id: 24797 Received: (qmail 96805 invoked by alias); 8 Dec 2017 09:20:28 -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 96176 invoked by uid 89); 8 Dec 2017 09:19:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, MANY_HDRS_LCASE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=trans, 36827, 36816, HContent-type:text X-HELO: mxout4.netvision.net.il MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII From: Arnold Robbins Message-id: <201712080916.vB89GxUJ005513@skeeve.com> Date: Fri, 08 Dec 2017 11:16:59 +0200 To: carlos@redhat.com, libc-alpha@sourceware.org Subject: [PATCH 12/17] Regex: Minor miscellaneous cleanups. User-Agent: Heirloom mailx 12.5 6/20/10 This patch supplies small code cleanups that didn't fall together with any of the other patches in this series. 2017-11-30 Arnold D. Robbins Minor miscellaneous cleanups. * posix/regcomp.c (re_compile_internal): Pass boolean to re_string_construct instead of random non-zero value. (build_equiv_class): Init char_buf[1] to '\0'. (build_charclass_op): Initialize br_token to zero. (create_tree): Initialize 't' to zero.. diff --git a/posix/regcomp.c b/posix/regcomp.c index 22c07ce..701855a 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -775,7 +775,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length, __libc_lock_init (dfa->lock); err = re_string_construct (®exp, pattern, length, preg->translate, - syntax & RE_ICASE, dfa); + (syntax & RE_ICASE) != 0, dfa); if (BE (err != REG_NOERROR, 0)) { re_compile_internal_free_return: @@ -3463,6 +3463,7 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name) return REG_ECOLLATE; /* Build single byte matching table for this equivalence class. */ + char_buf[1] = (unsigned char) '\0'; len = weights[idx1 & 0xffffff]; for (ch = 0; ch < SBC_MAX; ++ch) { @@ -3681,6 +3682,7 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, #endif /* Build a tree for simple bracket. */ + memset(& br_token, 0, sizeof(br_token)); /* silence "not initialized" errors froms static checkers */ br_token.type = SIMPLE_BRACKET; br_token.opr.sbcset = sbcset; tree = create_token_tree (dfa, NULL, NULL, &br_token); @@ -3771,6 +3773,7 @@ create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, re_token_type_t type) { re_token_t t; + memset(& t, 0, sizeof(t)); /* silence "not initialized" errors froms static checkers */ t.type = type; return create_token_tree (dfa, left, right, &t); } diff --git a/posix/regexec.c b/posix/regexec.c index 7b0f6d8..f14685a 100644 --- a/posix/regexec.c +++ b/posix/regexec.c @@ -630,7 +630,8 @@ re_search_internal (const regex_t *preg, const char *string, int length, fl_longest_match = (nmatch != 0 || dfa->nbackref); err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, - preg->translate, preg->syntax & RE_ICASE, dfa); + preg->translate, (preg->syntax & RE_ICASE) != 0, + dfa); if (BE (err != REG_NOERROR, 0)) goto free_return; mctx.input.stop = stop;