diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2019-04-16 14:49:07 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2019-04-16 14:49:07 +0000 |
commit | 74e493781b2e6675ea98a6814c91aa0debd2b802 (patch) | |
tree | 9178cc72132439783afda5c269f6a614194a7660 | |
parent | a9101e7b07d58fb45459787f34791e93915f76ad (diff) | |
download | pcre2-74e493781b2e6675ea98a6814c91aa0debd2b802.tar.gz |
Casts and rewrites to avoid clang sanitize warnings.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1085 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r-- | src/pcre2_compile.c | 10 | ||||
-rw-r--r-- | src/pcre2_printint.c | 3 | ||||
-rw-r--r-- | src/pcre2test.c | 4 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 30db6d5..ab48d2d 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -5948,7 +5948,10 @@ for (;; pptr++) (void)memmove(code + (32 / sizeof(PCRE2_UCHAR)), code, CU2BYTES(class_uchardata - code)); if (negate_class && !xclass_has_prop) - for (i = 0; i < 32; i++) classbits[i] = ~classbits[i]; + { + /* Using 255 ^ instead of ~ avoids clang sanitize warning. */ + for (i = 0; i < 32; i++) classbits[i] = 255 ^ classbits[i]; + } memcpy(code, classbits, 32); code = class_uchardata + (32 / sizeof(PCRE2_UCHAR)); } @@ -5971,7 +5974,10 @@ for (;; pptr++) if (lengthptr == NULL) /* Save time in the pre-compile phase */ { if (negate_class) - for (i = 0; i < 32; i++) classbits[i] = ~classbits[i]; + { + /* Using 255 ^ instead of ~ avoids clang sanitize warning. */ + for (i = 0; i < 32; i++) classbits[i] = 255 ^ classbits[i]; + } memcpy(code, classbits, 32); } code += 32 / sizeof(PCRE2_UCHAR); diff --git a/src/pcre2_printint.c b/src/pcre2_printint.c index a903826..36909ef 100644 --- a/src/pcre2_printint.c +++ b/src/pcre2_printint.c @@ -673,7 +673,8 @@ for(;;) map = (uint8_t *)ccode; if (invertmap) { - for (i = 0; i < 32; i++) inverted_map[i] = ~map[i]; + /* Using 255 ^ instead of ~ avoids clang sanitize warning. */ + for (i = 0; i < 32; i++) inverted_map[i] = 255 ^ map[i]; map = inverted_map; } diff --git a/src/pcre2test.c b/src/pcre2test.c index c9757e9..4010772 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -6861,7 +6861,7 @@ while ((c = *p++) != 0) fprintf(outfile, "** Truncation will probably give the wrong " "result.\n"); } - *q8++ = c; + *q8++ = (uint8_t)c; } } #endif @@ -6895,7 +6895,7 @@ while ((c = *p++) != 0) "result.\n"); } - *q16++ = c; + *q16++ = (uint16_t)c; } } #endif |