From: K.Kosako Date: Thu, 8 Aug 2019 05:06:07 +0000 (+0900) Subject: remove compiler warnings X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4aa8dad3a27f195031003906679c9a4f606c1a5;p=onig remove compiler warnings --- diff --git a/harnesses/deluxe-encode-harness.c b/harnesses/deluxe-encode-harness.c index e1f84a5..dde0d1a 100644 --- a/harnesses/deluxe-encode-harness.c +++ b/harnesses/deluxe-encode-harness.c @@ -49,39 +49,6 @@ search(regex_t* reg, unsigned char* str, unsigned char* end) return 0; } -static int -exec(OnigEncoding enc, OnigOptionType options, - char* apattern, char* apattern_end, char* astr, char* astr_end) -{ - int r; - regex_t* reg; - OnigErrorInfo einfo; - UChar* pattern = (UChar* )apattern; - UChar* str = (UChar* )astr; - UChar* pattern_end = (UChar* )apattern_end; - unsigned char *end = (unsigned char* )astr_end; - - onig_initialize(&enc, 1); - onig_set_retry_limit_in_match(DEFAULT_LIMIT); - onig_set_parse_depth_limit(DEFAULT_LIMIT); - - r = onig_new(®, pattern, pattern_end, - options, enc, ONIG_SYNTAX_DEFAULT, &einfo); - if (r != ONIG_NORMAL) { - char s[ONIG_MAX_ERROR_MESSAGE_LEN]; - onig_error_code_to_str((UChar* )s, r, &einfo); - fprintf(stdout, "ERROR: %s\n", s); - onig_end(); - return -1; - } - - r = search(reg, str, end); - - onig_free(reg); - onig_end(); - return 0; -} - static OnigCaseFoldType CF = ONIGENC_CASE_FOLD_MIN; static int diff --git a/harnesses/encode-harness.c b/harnesses/encode-harness.c index 5c8b2a7..ecad398 100644 --- a/harnesses/encode-harness.c +++ b/harnesses/encode-harness.c @@ -97,12 +97,31 @@ int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size) unsigned char *pattern_end; unsigned char *str_null_end; - - size_t remaining_size = Size; - unsigned char *data = (unsigned char *)(Data); + size_t remaining_size; + unsigned char *data; // pull off one byte to switch off - unsigned char encoding_choice = data[0]; +#if !defined(UTF16_BE) && !defined(UTF16_LE) + OnigEncodingType *encodings[] = { + ONIG_ENCODING_SJIS, + ONIG_ENCODING_EUC_JP, + ONIG_ENCODING_CP1251, + ONIG_ENCODING_ISO_8859_1, + ONIG_ENCODING_UTF8, + ONIG_ENCODING_KOI8_R, + ONIG_ENCODING_BIG5 + }; + + unsigned char encoding_choice; +#endif + + remaining_size = Size; + data = (unsigned char* )(Data); + +#if !defined(UTF16_BE) && !defined(UTF16_LE) + encoding_choice = data[0]; +#endif + data++; remaining_size--; @@ -120,16 +139,6 @@ int LLVMFuzzerTestOneInput(const uint8_t * Data, size_t Size) str_null_end = str + remaining_size; int r; - OnigEncodingType *encodings[] = { - ONIG_ENCODING_SJIS, - ONIG_ENCODING_EUC_JP, - ONIG_ENCODING_CP1251, - ONIG_ENCODING_ISO_8859_1, - ONIG_ENCODING_UTF8, - ONIG_ENCODING_KOI8_R, - ONIG_ENCODING_BIG5 - }; - OnigEncodingType *enc; #ifdef UTF16_BE