Skip to content

Commit 8bd201e

Browse files
committed
Avoid compiler warnings
1 parent 30a3acd commit 8bd201e

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/pcre2_fuzzsupport.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ If an argument starts with '=' the rest of it it is taken as a literal string
77
rather than a file name. This allows easy testing of short strings.
88
99
Written by Philip Hazel, October 2016
10+
Updated February 2024 (Addison Crump added 16-bit/32-bit and JIT support)
1011
***************************************************************************/
1112

1213
#include <errno.h>
@@ -47,6 +48,7 @@ Written by Philip Hazel, October 2016
4748
PCRE2_NOTEMPTY_ATSTART|PCRE2_PARTIAL_HARD| \
4849
PCRE2_PARTIAL_SOFT)
4950

51+
#if defined(SUPPORT_DIFF_FUZZ) || defined(STANDALONE)
5052
static void print_compile_options(FILE *stream, uint32_t compile_options)
5153
{
5254
fprintf(stream, "Compile options %.8x never_backslash_c", compile_options);
@@ -93,7 +95,10 @@ fprintf(stream, "%s%s%s%s%s%s%s%s%s\n",
9395
((match_options & PCRE2_PARTIAL_HARD) != 0)? ",partial_hard" : "",
9496
((match_options & PCRE2_PARTIAL_SOFT) != 0)? ",partial_soft" : "");
9597
}
98+
#endif /* defined(SUPPORT_DIFF_FUZZ || defined(STANDALONE) */
9699

100+
#ifdef SUPPORT_JIT
101+
#ifdef SUPPORT_DIFF_FUZZ
97102
static void dump_matches(FILE *stream, int count, pcre2_match_data *match_data)
98103
{
99104
#if PCRE2_CODE_UNIT_WIDTH == 8
@@ -131,8 +136,6 @@ for (int index = 0; index < count; index++)
131136

132137
/* This function describes the current test case being evaluated, then aborts */
133138

134-
#ifdef SUPPORT_JIT
135-
#ifdef SUPPORT_DIFF_FUZZ
136139
static void describe_failure(
137140
const char *task,
138141
const unsigned char *data,
@@ -204,8 +207,8 @@ if (matches_jit >= 0)
204207

205208
abort();
206209
}
207-
#endif
208-
#endif
210+
#endif /* SUPPORRT_DIFF_FUZZ */
211+
#endif /* SUPPORT_JIT */
209212

210213
/* This is the callout function. Its only purpose is to halt matching if there
211214
are more than 100 callouts, as one way of stopping too much time being spent on
@@ -303,8 +306,10 @@ for (i = 0; i < 2; i++)
303306
int errorcode;
304307
#ifdef SUPPORT_JIT
305308
int errorcode_jit;
309+
#ifdef SUPPORT_JIT_FUZZ
306310
int matches = 0;
307311
int matches_jit = 0;
312+
#endif
308313
#endif
309314
PCRE2_SIZE erroroffset;
310315
pcre2_code *code;
@@ -395,7 +400,10 @@ for (i = 0; i < 2; i++)
395400
errorcode_jit = pcre2_match(code, (PCRE2_SPTR)data, (PCRE2_SIZE)match_size, 0,
396401
match_options & ~PCRE2_NO_JIT, match_data_jit, match_context);
397402

398-
#ifdef SUPPORT_DIFF_FUZZ
403+
#ifndef SUPPORT_DIFF_FUZZ
404+
(void)errorcode_jit; /* Avoid compiler warning */
405+
#else
406+
399407
matches = errorcode;
400408
matches_jit = errorcode_jit;
401409

@@ -449,9 +457,9 @@ for (i = 0; i < 2; i++)
449457
pcre2_substring_free(bufferptr_jit);
450458
}
451459
}
452-
#endif
460+
#endif /* SUPPORT_JIT_FUZZ */
453461
}
454-
#endif
462+
#endif /* SUPPORT_JIT */
455463

456464
match_options = PCRE2_NO_JIT; /* For second time */
457465
}

0 commit comments

Comments
 (0)