From 3c7a67e2d6f371cf84587823e686bc14d14ebd02 Mon Sep 17 00:00:00 2001 From: Nick Wilson Date: Fri, 29 Nov 2024 11:02:03 +0000 Subject: [PATCH] Build warning fixes --- src/pcre2_compile.c | 19 +++++++++++++------ src/pcre2_compile_class.c | 4 ++-- src/pcre2_xclass.c | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 19d30d450..f97c0ca7c 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -6259,10 +6259,13 @@ for (;; pptr++) else { + BOOL need_map; + PCRE2_SIZE required_len; + PCRE2_ASSERT(op_info.op_single_type == ECL_XCLASS); - BOOL need_map = !allbitszero; - PCRE2_SIZE required_len = op_info.length + - (need_map? 32/sizeof(PCRE2_UCHAR) : 0); + need_map = !allbitszero; + required_len = + op_info.length + (need_map? 32/sizeof(PCRE2_UCHAR) : 0); if (lengthptr != NULL) { @@ -6273,13 +6276,17 @@ for (;; pptr++) } else { + PCRE2_UCHAR *rest; + PCRE2_SIZE rest_len; + PCRE2_UCHAR flags; + /* 1 unit: OP_XCLASS | LINK_SIZE units | 1 unit: flags | ...rest */ PCRE2_ASSERT(op_info.length >= 1 + LINK_SIZE + 1); - PCRE2_UCHAR *rest = op_info.code_start + 1 + LINK_SIZE + 1; - PCRE2_SIZE rest_len = (op_info.code_start + op_info.length) - rest; + rest = op_info.code_start + 1 + LINK_SIZE + 1; + rest_len = (op_info.code_start + op_info.length) - rest; /* First read any data we use, before memmove splats it. */ - PCRE2_UCHAR flags = op_info.code_start[1 + LINK_SIZE]; + flags = op_info.code_start[1 + LINK_SIZE]; PCRE2_ASSERT((flags & XCL_MAP) == 0); /* Next do the memmove before any writes. */ diff --git a/src/pcre2_compile_class.c b/src/pcre2_compile_class.c index 9b6954350..676fa0802 100644 --- a/src/pcre2_compile_class.c +++ b/src/pcre2_compile_class.c @@ -2141,8 +2141,8 @@ switch (meta) if ((flags & XCL_MAP) != 0) { - PCRE2_ASSERT( - code - code_start >= 1 + LINK_SIZE + 1 + 32 / sizeof(PCRE2_UCHAR)); + PCRE2_ASSERT(code - code_start >= + 1 + LINK_SIZE + 1 + 32 / (int)sizeof(PCRE2_UCHAR)); put_length = GET(code_start, 1) - 32 / sizeof(PCRE2_UCHAR); PUT(code_start, 1, (int)put_length); diff --git a/src/pcre2_xclass.c b/src/pcre2_xclass.c index fb68fb842..ab919250f 100644 --- a/src/pcre2_xclass.c +++ b/src/pcre2_xclass.c @@ -479,7 +479,7 @@ int stack_depth = 0; PCRE2_ASSERT(data_start < data_end); flags = *ptr++; PCRE2_ASSERT((flags & ECL_MAP) == 0 || - (data_end - ptr) >= 32 / sizeof(PCRE2_UCHAR)); + (data_end - ptr) >= 32 / (int)sizeof(PCRE2_UCHAR)); /* Code points < 256 are matched against a bitmap, if one is present. If no bitmap is present, then the ECLASS does not match any code points < 256. */