From 707dcab5ba0cc3392a1d95febffe1950cc9838e5 Mon Sep 17 00:00:00 2001 From: Ceyhun Alp Date: Thu, 26 Nov 2020 15:40:28 +0000 Subject: [PATCH] Replace DEFINEs with consts --- fuzzing/pdf_surface_fuzzer.c | 10 +++++----- fuzzing/raster_fuzzer.c | 3 --- fuzzing/text_glyphs_fuzzer.c | 6 +++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/fuzzing/pdf_surface_fuzzer.c b/fuzzing/pdf_surface_fuzzer.c index 33cb0e08b..5df3fbef6 100644 --- a/fuzzing/pdf_surface_fuzzer.c +++ b/fuzzing/pdf_surface_fuzzer.c @@ -2,10 +2,10 @@ #include #include "fuzzer_temp_file.h" -#define WIDTH_IN_INCHES 3 -#define HEIGHT_IN_INCHES 3 -#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0) -#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0) +const double width_in_inches = 3; +const double height_in_inches = 3; +const double width_in_points = width_in_inches * 72.0; +const double height_in_points = height_in_inches * 72.0; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cairo_t *cr; @@ -13,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cairo_status_t status; char *tmpfile = fuzzer_get_tmpfile(data, size); - surface = cairo_pdf_surface_create(tmpfile, WIDTH_IN_POINTS, HEIGHT_IN_POINTS); + surface = cairo_pdf_surface_create(tmpfile, width_in_points, height_in_points); status = cairo_surface_status(surface); if (status != CAIRO_STATUS_SUCCESS) { fuzzer_release_tmpfile(tmpfile); diff --git a/fuzzing/raster_fuzzer.c b/fuzzing/raster_fuzzer.c index 797d4e7c1..2e04f66ce 100644 --- a/fuzzing/raster_fuzzer.c +++ b/fuzzing/raster_fuzzer.c @@ -2,9 +2,6 @@ #include #include "fuzzer_temp_file.h" -#define WIDTH 200 -#define HEIGHT 80 - static cairo_surface_t * acquire (cairo_pattern_t *pattern, void *closure, cairo_surface_t *target, diff --git a/fuzzing/text_glyphs_fuzzer.c b/fuzzing/text_glyphs_fuzzer.c index 60d752934..d23cb88bc 100644 --- a/fuzzing/text_glyphs_fuzzer.c +++ b/fuzzing/text_glyphs_fuzzer.c @@ -1,10 +1,10 @@ #include #include "fuzzer_temp_file.h" -#define GLYPH_RANGE 9 +const int glyph_range = 9; int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - if (size < GLYPH_RANGE) { + if (size < glyph_range) { return 0; } cairo_t *cr; @@ -29,7 +29,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { cairo_text_extents(cr, buf, &extents); cluster.num_bytes = size; cluster.num_glyphs = 1; - for (int i = 0; i < 9; i++) { + for (int i = 0; i < glyph_range; i++) { // Taken from test/text-glyph-range.c cairo_glyph_t glyph = { (long int)data[i], 10 * i, 25