From 537286d0bb5021afe188cfba6100772bb0285e06 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 8 Nov 2022 18:13:00 +0900 Subject: [PATCH] Prevent GCC warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` regexec.c: In function ‘reset_match_cache’: regexec.c:1259:56: warning: suggest parentheses around ‘-’ inside ‘<<’ [-Wparentheses] 1259 | match_cache[k1 >> 3] &= ((1 << (8 - (k2 & 7) - 1)) - 1 << ((k2 & 7) + 1)) | ((1 << (k1 & 7)) - 1); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ regexec.c:1269:60: warning: suggest parentheses around ‘-’ inside ‘<<’ [-Wparentheses] 1269 | match_cache[k2 >> 3] &= ((1 << (8 - (k2 & 7) - 1)) - 1 << ((k2 & 7) + 1)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ regexec.c: In function ‘find_cache_index_table’: regexec.c:1192:11: warning: ‘m’ may be used uninitialized [-Wmaybe-uninitialized] 1192 | if (!(0 <= m && m < num_cache_table && table[m].addr == p)) { | ~~^~~~ regexec.c: In function ‘match_at’: regexec.c:1238:12: warning: ‘m1’ is used uninitialized [-Wuninitialized] 1238 | if (table[m1].addr < pbegin && m1 + 1 < num_cache_table) m1++; | ^ regexec.c:1218:39: note: ‘m1’ was declared here 1218 | int l = 0, r = num_cache_table - 1, m1, m2; | ^~ regexec.c:1239:12: warning: ‘m2’ is used uninitialized [-Wuninitialized] 1239 | if (table[m2].addr > pend && m2 - 1 > 0) m2--; | ^ regexec.c:1218:43: note: ‘m2’ was declared here 1218 | int l = 0, r = num_cache_table - 1, m1, m2; | ^~ ``` --- regexec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/regexec.c b/regexec.c index acf03f2501c36d..94d03241a53304 100644 --- a/regexec.c +++ b/regexec.c @@ -1175,7 +1175,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, static int find_cache_index_table(regex_t* reg, OnigStackType *stk, OnigStackIndex *repeat_stk, OnigCacheIndex* table, int num_cache_table, UChar* p) { - int l = 0, r = num_cache_table - 1, m; + int l = 0, r = num_cache_table - 1, m = 0; OnigCacheIndex* item; OnigRepeatRange* range; OnigStackType *stkp; @@ -1215,7 +1215,7 @@ static int find_cache_index_table(regex_t* reg, OnigStackType *stk, OnigStackInd } static void reset_match_cache(regex_t* reg, UChar* pbegin, UChar* pend, int pos, uint8_t* match_cache, OnigCacheIndex *table, int num_cache_size, int num_cache_table) { - int l = 0, r = num_cache_table - 1, m1, m2; + int l = 0, r = num_cache_table - 1, m1 = 0, m2 = 0; int is_inc = *pend == OP_REPEAT_INC || *pend == OP_REPEAT_INC_NG; OnigCacheIndex *item1, *item2; int k1, k2; @@ -1256,7 +1256,7 @@ static void reset_match_cache(regex_t* reg, UChar* pbegin, UChar* pend, int pos, k2 += base; if ((k1 >> 3) == (k2 >> 3)) { - match_cache[k1 >> 3] &= ((1 << (8 - (k2 & 7) - 1)) - 1 << ((k2 & 7) + 1)) | ((1 << (k1 & 7)) - 1); + match_cache[k1 >> 3] &= (((1 << (8 - (k2 & 7) - 1)) - 1) << ((k2 & 7) + 1)) | ((1 << (k1 & 7)) - 1); } else { int i = k1 >> 3; if (k1 & 7) { @@ -1266,7 +1266,7 @@ static void reset_match_cache(regex_t* reg, UChar* pbegin, UChar* pend, int pos, if (i < (k2 >> 3)) { xmemset(&match_cache[i], 0, (k2 >> 3) - i); if (k2 & 7) { - match_cache[k2 >> 3] &= ((1 << (8 - (k2 & 7) - 1)) - 1 << ((k2 & 7) + 1)); + match_cache[k2 >> 3] &= (((1 << (8 - (k2 & 7) - 1)) - 1) << ((k2 & 7) + 1)); } } }