diff --git a/tools/gbcpal.c b/tools/gbcpal.c index 0944073121..b5cdeea8b0 100644 --- a/tools/gbcpal.c +++ b/tools/gbcpal.c @@ -48,7 +48,7 @@ double luminance(struct Color color) { int compare_colors(const void *color1, const void *color2) { double lum1 = luminance(*(const struct Color *)color1); double lum2 = luminance(*(const struct Color *)color2); - return lum1 > lum2 ? -1 : lum1 < lum2; // sort lightest to darkest + return (lum1 < lum2) - (lum1 > lum2); // sort lightest to darkest } void read_gbcpal(const char *filename, struct Color **colors, size_t *num_colors) { diff --git a/tools/make_patch.c b/tools/make_patch.c index 1218339f42..3a36accdd8 100644 --- a/tools/make_patch.c +++ b/tools/make_patch.c @@ -417,7 +417,7 @@ struct Buffer *process_template(const char *template_filename, const char *patch int compare_patch(const void *patch1, const void *patch2) { unsigned int offset1 = ((const struct Patch *)patch1)->offset; unsigned int offset2 = ((const struct Patch *)patch2)->offset; - return offset1 < offset2 ? -1 : offset1 > offset2; + return (offset1 > offset2) - (offset1 < offset2); } bool verify_completeness(FILE *restrict orig_rom, FILE *restrict new_rom, struct Buffer *patches) {