aboutsummaryrefslogtreecommitdiffstats
path: root/regexec.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-11-08 18:13:00 +0900
committerYusuke Endoh <mame@ruby-lang.org>2022-11-09 23:21:26 +0900
commit537286d0bb5021afe188cfba6100772bb0285e06 (patch)
tree94df6581a40edf09edf3a4d1854b90fb42749681 /regexec.c
parentff5dba831910c91e293220b652be868e9cfdc8e1 (diff)
downloadruby-537286d0bb5021afe188cfba6100772bb0285e06.tar.gz
Prevent GCC warnings
``` 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; | ^~ ```
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/regexec.c b/regexec.c
index acf03f2501..94d03241a5 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));
}
}
}