]> granicus.if.org Git - onig/commitdiff
remove compiler warnings
authorK.Kosako <kosako@sofnec.co.jp>
Thu, 8 Aug 2019 05:06:07 +0000 (14:06 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Thu, 8 Aug 2019 05:06:07 +0000 (14:06 +0900)
harnesses/deluxe-encode-harness.c
harnesses/encode-harness.c

index e1f84a55755f1f179467ecb46e5fb7409e35ad86..dde0d1a50e2fc6fd17534ae789fb9c1d91f10eaa 100644 (file)
@@ -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(&reg, 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
index 5c8b2a76408112239595d2aaa9b89590c1400184..ecad398fe093e49cff74c7beff0ce6f0ef526fab 100644 (file)
@@ -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