From 5f9f09e5778a57df986950fc8e4ffeed3b4eeb94 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Mon, 18 Nov 2024 18:23:32 +0300 Subject: [PATCH] corrupter.*: use type `byte` where appropriate --- include/corrupter.h | 6 ++++-- src/corrupter.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/corrupter.h b/include/corrupter.h index 3a63667..87bbfbd 100644 --- a/include/corrupter.h +++ b/include/corrupter.h @@ -17,6 +17,9 @@ #include "file_boundaries.h" #include "file_type.h" +/* typedefs */ +typedef unsigned char byte; + /* structures */ struct _corrupter_result { bool error; @@ -28,7 +31,7 @@ struct _corrupter_result { struct _corrupter_param { FILE* file; uint16_t probability; - uint8_t threshold; + byte threshold; size_t passes; uint8_t config; uint32_t* seed; @@ -38,7 +41,6 @@ struct _corrupter_param { /* typedefs */ typedef struct _corrupter_param Corrupter_Param; typedef struct _corrupter_result Corrupter_Result; -typedef unsigned char byte; /* macros: procedures */ #ifdef DEBUG diff --git a/src/corrupter.c b/src/corrupter.c index cd2132d..9107750 100644 --- a/src/corrupter.c +++ b/src/corrupter.c @@ -100,7 +100,7 @@ Corrupter_Result* corrupt_file(Corrupter_Param* param) { continue; // generate bit mask - unsigned char damage_left = (unsigned char) param->threshold; + byte damage_left = param->threshold; static bool bit_mask[CHAR_BIT]; for (unsigned char bit = 0; bit < CHAR_BIT; bit++) { @@ -114,7 +114,7 @@ Corrupter_Result* corrupt_file(Corrupter_Param* param) { bool damaged_byte = false; - for (unsigned char bit = 0; bit < threshold; bit++) { + for (byte bit = 0; bit < threshold; bit++) { if (bit_mask[bit] == false) continue;